The following test doesn't work, the code following is always executed : if(!session_id()) { // Always executed even if there's already an opened session } session_id() returns an empty string if there is no current session, so to test if a session already exists, it's better to write this : if(session_id() == "") { session_start(); } else { // Anything you want }
所以呢sission_id应该在session_start之后!!
session_id(XXX)用在session_start()之前
The following test doesn't work, the code following is always executed : if(!session_id())
{
// Always executed even if there's already an opened session
} session_id() returns an empty string if there is no current session, so to test if a session already exists, it's better to write this :
if(session_id() == "")
{
session_start();
}
else
{
// Anything you want
}
后
session_id(XXX)用在session_start()之前还是之后?
前