tags:

views:

97

answers:

3

i have a problem, can't understund anyway.

i have three files - index.php, admin.php, post.php

in index.php i have

<?
session_start();
$_SESSION['login11_error'] = 'yes';
if(verifying username and password here, if they correct)
{
     $_SESSION['login11_error'] = 'no';
     header('Location: admin.php');
}
?>

in admin.php i have

<?
session_start();
<form action="post.php" method="post">
...
?>

and finaly in post.php

<?
session_start();
some functions here...
header("location:admin.php");
?>

but when it redirected to admin.php from post.php it lose the value of $_SESSION['login11_error'].

any ideas?

Thanks...

UPDATE

fixed.

because i just show the structure of script here, i have a mistake in my question.

post php is in another folder, then index.php and admin.php, it's in /folder1/folder1_1/post.php

in post.php i was writing header('Location: http://bs.am/admin.php")

and when i change it to header('Location: ../../admin.php") it start working.

incomprehensible behavior for me, but works:)

+2  A: 

Syom,

I don't see anything obviously wrong with your sample code.

If the redirect from index.php to admin.php works (persists your session variable), then there must be something screwy happening in post.php. Can you comment out all of your code in post.php and simply redirect to admin.php? That is, post.php would only contain:

<?
header('Location: admin.php');
?>

If echo $_SESSION['login11_error']; (in admin.php, after your start_session() of course) prints something, start uncommenting items in post.php.

If you're at a stand still, copy the example from http://www.php.net/manual/en/function.session-start.php and make sure it works for you.

labratmatt
i try to delete all data from `post.php`. and what is strange - i have the variable correct in post.php(i try to print it there), but when it redirect to admin.php, it deletes it's value...
Syom
Syom,There must be something going on in post.php, because the redirect logic used in index.php (header('Location: admin.php');) works (right?).
labratmatt
i fixe it, see the update. but very strange behavior i think. why i can't write the whole url in header?
Syom
A: 

try to set session_name('MySESS'); manually before every session_start()

GOsha
+2  A: 

in post.php i was writing header('Location: http://bs.am/admin.php")

and when i change it to header('Location: ../../admin.php") it start working.

incomprehensible behavior for me, but works:)

Syom