How can we know that a session is started or not?

Answers were Sorted based on User's Feedback



How can we know that a session is started or not?..

Answer / 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

How can we know that a session is started or not?..

Answer / rahul

on head of the page we have to write
session_start();
statement.

Is This Answer Correct ?    3 Yes 9 No

How can we know that a session is started or not?..

Answer / kamlesh

we can check is_session_start() by this function.

Is This Answer Correct ?    3 Yes 9 No

Post New Answer

More PHP Interview Questions

Explain the difference between urlencode and urldecode?

0 Answers  


Do while loops php?

0 Answers  


PHP can be used frontend of for backend?

3 Answers   Global Logic,


How do I update php?

0 Answers  


Explain what are the three classes of errors that can occur in php?

0 Answers  






Do while loops?

0 Answers  


What is php in simple words?

0 Answers  


What are the ways to include file in php?

0 Answers  


What is a helper function?

0 Answers  


How to call php function from javascript using ajax?

0 Answers  


How to convert strings in hex format?

0 Answers  


What is singleton class in php?

0 Answers  


Categories