Test if session is started
Asked Answered
I

2

6

How do you test to see if sessions are on. This is not the way...

session_start();
if(isset($_SESSION)) {
    echo "sessions ON<br>";
}
else{
    echo "sessions OFF<br>";
}

session_destroy();
if(isset($_SESSION)) {
    echo "sessions ON<br>";
}
else{
    echo "sessions OFF<br>";
}
Inappreciative answered 28/7, 2010 at 21:42 Comment(1)
Check thisAgrobiology
N
5

Try this:

if(session_id())

http://php.net/manual/en/function.session-id.php

Nolly answered 28/7, 2010 at 21:44 Comment(0)
P
2

session_start() itself will return boolean TRUE if the session was started successfully, boolean FALSE if not.

Piemonte answered 28/7, 2010 at 21:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.