Jump to content


Photo

How to check if session is already present?


  • Please log in to reply
4 replies to this topic

#1 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 21 September 2006 - 06:34 PM

I have a registration form that, if registration is successful, starts and sets the session ID. What I want to do is have it check if the session has already been started so that they don't try to register twice in the same session.

if (!$_SESSION['loggedin'] == true)
{
header("Location: login.php");
} else
{
blah blah proceed with registration
}

I'm just not sure on my syntax but that's the jist of what I need.

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 21 September 2006 - 06:35 PM

That should work.

#3 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 21 September 2006 - 06:42 PM

Ok, thanks. But maybe it should be an isset function?

if (isset($_SESSION['loggedin']))
{
  header("Location: login.php");
} else {
  run code blah blah;
}

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 21 September 2006 - 06:45 PM

Could be, but doesn't really matter. If it is true then it is set, right ;)

#5 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 21 September 2006 - 07:30 PM

heh...well, it only matters if the code works ;)  I'm going to use the isset function and see how things progress from there. Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users