日期:2014-05-17 浏览次数:20511 次
一. Session的配置与应用
?
1.?bool session_start( void ); ? ? ? ? ?--?Initialize session data
2. $_SESSION[name] = value; ? ? ? ? ? ? -- Config session data
3. echo $_SESSION[name]; ? ? ? ? ? ? ? ?-- Use session
4. isset($_SESSION[name]); ? ? ? ? ? ? ?-- 判断session是否已配置
5. unset($_SESSION[name]); ? ? ? ? ? ? ?-- 删除session变量
6.?bool session_destroy( void ); ? ? ? ?-- 删除所有session
?
* session_register,session_unregister, session_is_registered在PHP5中不再使用.
? ? 简单示例:
<?php // Initialize the session. // If you are using session_name("something"), don't forget it now! session_start(); // Unset all of the session variables. $_SESSION = array(); // If it's desired to kill the session, also delete the session cookie. // Note: This will destroy the session, and not just the session data! if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time()-42000, '/'); } // Finally, destroy the session. session_destroy(); ?>?
?