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


Please Help Members By Posting Answers For Below Questions

What do you mean by core php?

491


How many types of arrays are there in php?

538


What are the differences between echo and print?

562


What is csrf token and why it is required?

542


Tell me how can we change the maximum size of the files to be uploaded?

553






What is mysql_fetch_object?

560


When to use get and post request?

553


Why shouldn't I use mysql_* functions in php?

598


How to know user has read the email-php?

499


What is difference between python and php?

519


Which function parses an English textual date or time into Unix timestamp in PHP.

579


How to connect to mysql from a php script?

561


How is it possible to parse a configuration file?

512


Explain some most commonly use string functions in php?

507


What is urlencode and urldecode in php?

581