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

How to communicate with sockets in php?

1 Answers  


1. Create student database. 2. First page should display the students available in the database. There should be add, edit and delete buttons. 3. There should be option to search students by name, code, date of joining, department or combination of these. 4. Should have an add/edit screen. Add and Edit should be handled in the same page. 5. Delete should ask for confirmation before deleting the actual record. 6. Validation should be done in JavaScript as well as php.

0 Answers   Zonex,


Which one is best framework for php?

0 Answers  


What are php magic methods?

0 Answers  


Which is better php or wordpress?

0 Answers  






Explain Booleans in PHP?

0 Answers  


What is cookie and session in php?

0 Answers  


How can we optimize or increase the speed of a mysql select query?

6 Answers  


What is mysqli_query?

0 Answers  


What will the ?getdate() function returns in PHP?

0 Answers  


How can I embed a java program in php file and what changes have to be done in php.ini file?

0 Answers  


What are the advantages of indexes?

0 Answers  


Categories