在 session_destroy() 之后保留会话变量 [英] preserving a session variable after session_destroy()

查看:32
本文介绍了在 session_destroy() 之后保留会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自我的 logout.php :

from my logout.php :

<?php require_once("includes/session.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php
  if ( isset( $_SESSION['colony_id']))
    $cookie = $_SESSION['colony_id'] ;
  $_SESSION = array();
  if(isset($_COOKIE[session_name()])) {
    setcookie(session_name(), '', time()-42000, '/');
  }
  session_destroy();
    //this fails-  session_start() ;   
    if ( !empty($cookie))
      $_SESSION['colony_id'] = $cookie ;    
    // redirect_to("login.php?logout=1");
?>

我想结束当前会话,然后开始一个新会话,在新会话中使用旧会话中的一个变量.我尝试添加第二个 session_start 语句,但没有效果.我还能做什么?

I want to end the current session and then start a new session, with one of the variables from the old session in the new session. I tried adding a second session_start statement, but that had no effect. What else can I do ?

谢谢

我决定重定向到一个新页面,一个新的 session_start() 语句在该页面上创建了一个新会话

I decided to redirect to a new page, on which a fresh session_start() statement created a new session

推荐答案

查看此链接:

http://bugs.php.net/bug.php?id=38042

这是 php 中的一个错误,它有一个补丁.

it's a bug in php and it has a patch.

这篇关于在 session_destroy() 之后保留会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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