Shelley Shyan wrote:
Hi all,
Maybe this is a somehow stupid question.
I want to know how php could know whether session_start() has been called, that is, whether session has been started.
I Googled, but got little help.
Thank you for help!
Any tip is greatly appreciated.
Regards,
Shelley
http://us3.php.net/session_id
is what you are looking for.
Look at the notes for the "Return Values" section
"session_id() returns the session id for the current session or the
empty string ("") if there is no current session (no current session id
exists)."
So, something like this will do.
<?php
$sid = session_id();
if ( $sid == '' ) {
// No session started yet.
} else {
// Session has been started.
}
?>
Jim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php