ways of checking if a session is active
function session_started(){
if(isset($_SESSION)){ return true; }else{ return false; }
}
//Start the output buffer so we dont create any errors with headers
ob_start();
//Check to see if it has been started
if(session_started()){
echo 'The session has been started.';
}else{
echo 'The session has not been started.';
}
//Start the session
echo 'Starting Session...';
session_start();
//Check again
if(session_started()){
echo 'The session has been started.';
}else{
echo 'The session has not been started.';
}
//Flush the buffer to screen
ob_end_flush();
Nhận xét
Đăng nhận xét