Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2010
    Location
    London
    Posts
    339
    Thanks
    63
    Thanked 11 Times in 11 Posts

    Using isset to check a session

    Hi there.

    For my login system the session 'myemail' is set when the user logs in. To check whether the user is logged in I used to use this...

    PHP Code:
    if(!session_is_registered(myemail))
    {
    header("location:login.php");

    ...but I realise this is now deprecated. Is the way below a safe and practical way of solving this?

    PHP Code:
    if(!isset($_SESSION['myemail']))
    {
    header("location:login.php");
    }
    ?> 
    Thanks.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,474
    Thanks
    63
    Thanked 537 Times in 524 Posts
    Yes the second way is the way forward and is indeed recommended.
    I can't really think of anything to write here now...

  • #3
    Regular Coder
    Join Date
    Dec 2010
    Location
    London
    Posts
    339
    Thanks
    63
    Thanked 11 Times in 11 Posts
    thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •