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
Do csrf tokens expire?
What is the difference between $var and $$var?
What is a composer in PHP?
What is php explain?
Explain preg_Match and preg_replace?
What is the difference between md5(), crc32() and sha1() crypto on php?
What are computer variables?
Is age an interval or ratio?
What is the use of array_count_values() in php?
Is php a low level language?
What is the function of trim?
What are the differences between session and cookie?
Tell me how can we determine whether a php variable is an instantiated object of a certain class?
What is the use of strpos in php?
What is polymorphism with example in php?