可以不设置session_start();
可以直接在php.ini 里面
; Initialize session on request startup.
session.auto_start = 1
等于一就可以了
session.auto_start = 1
然后apache重启即可
一般销毁方法
<?php
session_start();
session_unset();
session_destroy();
?>
<?php
session_start();
$_SESSION = array();
session_destroy();
?>
session_destroy用于在后台销毁一个会话,销毁当前session,session_unset用于清空当前会话的所有变量
会话销毁了不等于你设置的session变量也没了
Don't Forget
,不要忘记设置session文件的保存的路径
; NOTE 1: PHP will not create this directory structure automatically.
; You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
; use subdirectories for session storage
session.save_path = "D:/php4/php-4.3.9-Win32/session"