Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to check if user's session is already started in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 524
    Comment on it

    If you want to know weather the session is already begin or not in PHP then, you can use of the syntax from PHP manual

    see the example below

    1. if (!isset($_SESSION)) session_start();

    2. And in case you are using PHP < 5.4 you have to the code below:

    if (version&_compare(phpversion(), '5.4.0', '<')) {
         if(session&_id() == '') {
            session&_start();
         }
     }
     else
     {
        if (session&_status() == PHP&_SESSION&_NONE) {
            session&_start();
        }
     }
    

    In the code above the benefit is your code will works fine whatever is you php version

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: