Reputation: 23149
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:)
Upvotes: 1
Views: 437
Reputation: 23149
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:)
Upvotes: 1
Reputation: 689
try to set session_name('MySESS');
manually before every session_start()
Upvotes: 0
Reputation: 1841
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.
Upvotes: 2