Re: A stupid question?
| From: | Jim Lucas | Date: | Fri, 18 Jan 2008 02:53:30 +0000 |
| Subject: | Re: A stupid question? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-267524@lists.php.net to get a copy of this message | ||
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, Shelleyhttp://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