首頁  >  文章  >  後端開發  >  PHP5中Session小结(一)

PHP5中Session小结(一)

WBOY
WBOY原創
2016-06-13 10:39:21749瀏覽

PHP5中Session总结(一)

一. 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();?>
?

?

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn