我有三个文件。
文件 1:index.php
它重定向到 second.php 并将 id=$var 发送到 second.php。
代码:
$var=52013;
window.open('second.php?id=$var','name','width=1000,height=700,scrollbars=yes');
文件2:第二个.php
在我收到的这个文件中$var
,当我在日志中打印它时,它显示的值为$var
.
<?php
session_start();
$_SESSION['id'] = $_REQUEST['id'];
$GLOBALS["log"]->fatal("Get id of order = ".$_SESSION['id']);
//Here it redirects to third file for some varification online.
//This condition is true first time when this page is called but after
//redirection from third.php this condition becomes false.So code below
//this if statement will be executed after redirection from third file.
if(condition==true)
{
header("Location: http://third.php");
}
print "Please visit:\n$authUrl\n\n";
print "Please enter the auth code:\n";
//After redirection from third.php i want to write document using value stored
//in session variable which we get at top.($_SESSION['id'])
$val = $_SESSION['id'];
//Write a file
$file_open = fopen("modules/doc/views/document.txt","wb");
$content = $val;
fwrite($file_open,$content);
fclose($file_open);
文件 3:Third.php
该文件在线进行一些修改,然后重定向到 second.php 以便在 document.txt 中写入会话 ID
所以问题是当 third.php 重定向到 second.php 文件时,会话变量会丢失它的值。我想在从 third.php 重定向后在 document.txt 中写入会话变量的值,但当时$_SESSION['id']
什么都不包含。
但过程应该是一样的,我不想改变它。这是要求。
即 index.php -> second.php -> third.php -> second.php -> 写入会话值。
谢谢