Heim  >  Artikel  >  Backend-Entwicklung  >  PHP5中Session小结(一)

PHP5中Session小结(一)

WBOY
WBOYOriginal
2016-06-13 10:39:21749Durchsuche

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

?

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php性能(内存)有关问题Nächster Artikel:PHP5中Cookie小结(一)