By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,335 Members | 2,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,335 IT Pros & Developers. It's quick & easy.

How do I know if a Session has been started?

100+
P: 103
Can anyone advise me on a function / built in function / technique to check if a session is already set?

It relates to a login system where I have every page start a session with session_start() then when I regsiter a user, I have the registration functions run the overall login script after the user is registered. This calls the session_start() function so I wanted to put a quick check in the way to prevent the error.

Thanks!!!

Henry
Jun 4 '07 #1
Share this Question
Share on Google+
2 Replies


pbmods
Expert 5K+
P: 5,821
Changed thread title to better match contents (and to remove annoying '?!?'s).

Perhaps session_id will help....
Jun 4 '07 #2

P: 93
I stole this from here:
http://uk2.php.net/manual/en/function.session-start.php


[PHP]$_SESSION['testMe']='test';
@session_start();

if(isset($_SESSION['testMe']))
{
echo "Session was open\n";
unset($_SESSION['testMe']);
}
else
echo "Session was closed\n";
[/PHP]
Jun 4 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.