note 54084 modified in function.session-id by danbrown
| From: | danbrown@php.net | Date: | Tue, 11 Nov 2008 16:15:42 +0000 |
| Subject: | note 54084 modified in function.session-id by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146389@lists.php.net to get a copy of this message | ||
About the note from Cybertinus :
The following test doesn't work, the code following is always executed :
<?php
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
}
?>
--was--
About the note from Cybertinus :
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
}
http://php.net/manual/en/function.session-id.php