重定向时丢失 $_SESSION[] 的值 [英] Lose the value of $_SESSION[] when redirect

查看:50
本文介绍了重定向时丢失 $_SESSION[] 的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,无论如何都无法理解.

i have a problem, can't understund anyway.

我有三个文件 - index.phpadmin.phppost.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:)

这篇关于重定向时丢失 $_SESSION[] 的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆