Page 1 of 1

can we give session a name like function in php

Posted: Sat Dec 20, 2008 5:15 am
by anujphp
Hello
the below code i got in forum to check where a user is logged in or not

Code: Select all

<?php
if (isset($_SESSION['session_name_here'])) {
//  Code to be run here
 
}
?>
can anyone tell me what is this session_name_here means...
in my login page i am not giving any name to the session i am starting the session and saving name and other data in variable..
does this means the name i save in variable or it is that i can give a name to session like we give to a function
THANK YOU IN ADVANCE

Re: can we give session a name like function in php

Posted: Sat Dec 20, 2008 5:24 am
by Mark Baker
anujphp wrote:in my login page i am not giving any name to the session i am starting the session and saving name and other data in variable..
does this means the name i save in variable or it is that i can give a name to session like we give to a function
$_SESSION is just an array, so you can set index keys for entries in that array exactly as you can do using $array = array( 'First' => 123.456, 'Second' => 'My Second array value');

If you don't give the entry a name, it will use 'session_name_here' as its entry key.