重定向时丢失 $_SESSION[] 的值
我有一个问题,无论如何都无法理解.
i have a problem, can't understund anyway.
我有三个文件 - index.php
、admin.php
、post.php
i have three files - index.php
, admin.php
, post.php
在 index.php
我有
<?
session_start();
$_SESSION['login11_error'] = 'yes';
if(verifying username and password here, if they correct)
{
$_SESSION['login11_error'] = 'no';
header('Location: admin.php');
}
?>
在 admin.php
我有
<?
session_start();
<form action="post.php" method="post">
...
?>
最后在 post.php
<?
session_start();
some functions here...
header("location:admin.php");
?>
但是当它从 post.php
重定向到 admin.php
时,它丢失了 $_SESSION['login11_error']
的值.
but when it redirected to admin.php
from post.php
it lose the value of $_SESSION['login11_error']
.
有什么想法吗?
谢谢...
更新
已修复.
因为我只是在这里展示脚本的结构,所以我的问题有一个错误.
because i just show the structure of script here, i have a mistake in my question.
post php 在另一个文件夹,然后是 index.php 和 admin.php,在 /folder1/folder1_1/post.php
post php is in another folder, then index.php and admin.php, it's in /folder1/folder1_1/post.php
在 post.php 中我正在写 header('Location: http://bs.am/admin.php")
in post.php i was writing header('Location: http://bs.am/admin.php")
当我将其更改为 header('Location: ../../admin.php")
时,它开始工作.
and when i change it to header('Location: ../../admin.php")
it start working.
对我来说难以理解的行为,但有效:)
incomprehensible behavior for me, but works:)
in post.php i was writing header('Location: http://bs.am/admin.php")
in post.php i was writing header('Location: http://bs.am/admin.php")
当我将其更改为 header('Location: ../../admin.php") 时,它开始工作.
and when i change it to header('Location: ../../admin.php") it start working.
对我来说难以理解的行为,但有效:)
incomprehensible behavior for me, but works:)