使用php在目录遍历中维护会话

时间:2011-07-04 05:28:40

标签: php

我是php新手...我正在尝试在目录遍历脚本中维护会话...但是每次我去子目录时我的会话变量都会丢失...
现在我的脚本看起来像 -

start_session();          

//login and authenticate using functions in included scripts 
//(include(login.php);include(auth.php)) and set session variables accordingly  

if (session variable is set)
{
    //start the traversal script
}  

所以我想知道的是如何在目录遍历中管理会话....任何人都可以帮助我...

1 个答案:

答案 0 :(得分:0)

http://www.php.net/manual/en/function.session-start.php

session_start();

if (isset($_SESSION['directory_path'])) {
   $directory_path = $_SESSION['directory_path'];
} else {
   $directory_path = 'default/path';
}

// traverse with path

$_SESSION['directory_path'] = $new_directory_path;