How can we know that a session is started or not?
Answer Posted / deep
we'll have to set a session variable after starting a
session as shown below
--------------------------------------------------
<?php
session_start();
if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo "Views=". $_SESSION['views'];
?>
--------------------------------------------------
it will set as well as increment the session variable
or we may simply echo a value to check whether a session is
started or not.
| Is This Answer Correct ? | 10 Yes | 0 No |
Post New Answer View All Answers
If we login more than one browser windows at the same time with same user and after that we close one window, then is the session is exist to other windows or not? And if yes then why? If no then why?
What is the role of php.ini file?
What is scope of variable in php?
What is difference between include and include_once in php?
How to protect special characters in query string?
What is the use of anonymous function in php?
In php how can you jump in to and out of "php mode"?
Is php harder than javascript?
Explain difference between urlencode and urldecode?
What is laravel php?
What is use of header() function in php?
Why post method is used in php?
Tell me what are the functions to be used to get the image's properties (size, width and height)?
How a variable is declared in php?
What is htaccess in php?