You are here: Re: newbie: session_start() question « PHP Language « IT news, forums, messages
Re: newbie: session_start() question

Posted by Colin McKinnon on 01/02/07 23:56

Jeff wrote:

> Hey
>
> I'm using php version 5.2.0
>
> I'm wondering how we can tell if session_start are resuming the current
> session id or if it just created a new session?
>
> I know I could for example do a test like this: $_SESSION["valid_user"] ==
> NULL (not sure about the syntax).. but there must be a better way to
> determine if session_start() starts a new session or not?
>

It's a lot simpler if you only use cookie based sessions. But something
like:

$started_with = ini_get('use_trans_sid') ?
$_GET[session_name()] :
$_COOKIE[session_name()];
// $started with was the the session identifier passed at start up
// of course this doesn't mean it refers to a valid session...
if ($started_with == session_id()) {
// we have resumed an existing session
}

That's rather complicated though - if a session has been started or resumed,
then $_SESSION will be an array (but maybe an empty one).

if (is_array($_SESSION)) {
// a session has been started or resumed
}

HTH

C.


}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация