Re: PHP Sessions
| From: | Chris Shiflett | Date: | Thu, 10 Apr 2003 17:58:45 +0000 |
| Subject: | Re: PHP Sessions | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143373@lists.php.net to get a copy of this message | ||
Joe,
--- Joe McKarthur <php@potus.net.ar> wrote:
> What should i do to get the status of a session, i mean, if a session was
> already started or the user that entered the page doesnt have a session
> registered?
The easiest way (in my opinion) is to set a session variable for every session:
$_SESSION['foo'] = 'bar';
It can be anything, and I usually use a session variable that I'm actually
using rather than something made up specifically for this purpose.
Then, you can simply test for the existence of this session variable after you
start the session:
if (!isset($_SESSION['foo']))
{
echo 'This is a new session';
$_SESSION['foo'] = 'bar';
}
else
{
echo 'This is a returning session';
}
> Excuse my english..
Your English is very good. :-)
Chris
=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/