can we give session a name like function in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anujphp
Forum Commoner
Posts: 25
Joined: Wed Nov 05, 2008 10:12 am

can we give session a name like function in php

Post 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
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

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

Post 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.
Post Reply