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

please send me the interview questions and answers to my mail id : srikanthgovardana@yahoo.com or srikanthgovardana@gmail.com

0 Answers  


What is a trait in php?

1 Answers  


What does php mean?

1 Answers  


What is the difference between file_get_contents() and file_put_contents() in php?

1 Answers  


What does trim () do in javascript?

1 Answers  


What is php oop?

1 Answers  


Whether session will work if we disable cookies in client browser ?

10 Answers  


Which function(s) in PHP computes the difference of arrays?

1 Answers  


Require_once(), require(), include(). What is difference between them?

1 Answers  


How to pad an array with the same value multiple times?

1 Answers  


What are the differences between require and include, include_once?

3 Answers  


What is difference between strstr() and stristr()?

1 Answers  


Categories