English 中文(简体)
销毁 Null 会话变量
原标题:Destroying Null Session Variables

我为自己的网站创建了会话。

session_start();
if(isset($_SESSION[ User ]))
{
  //session_start();
  $sesvar = $_REQUEST[ sid ];
} 
else
{
  $sesvar = " ";
}

但当我点击退出退出按钮会话时, 会话会被销毁。 但是 sid( 设置会话变量的参数) 值被设为无效 。 要销毁会话, i 写入以下代码 :

if(isset($_REQUEST[ out ]))
{
    session_start();
    session_unset();
    //unset($_SESSION[ User ]);
    session_destroy();
    header("Location:login.html");
    exit;   
}

在我获得 sid=null 时登出后, 如果点击网站的任何链接, 欢迎 msg 仍然存在, 有无效会话变量 。 请帮助 。

问题回答

您实际上没有使用会话变量存储会话数据。

i 假设在以下代码中您正试图使用会话变量存储某些值

$sesvar = $_REQUEST[ sid ];

您正在错误地这样做, 以便存储您需要的任何会话数据, 以将其存储为超级全局 $_SESSION 阵列。 例如 。

$_SESSION[ var ] = $_REQUEST[ sid ];

并检查或获取您在 $_SESSION 中检查值所需的值





相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签