Jump to content

[SOLVED] can we give session a name like function in php


anujphp

Recommended Posts

Hello

the below code i got in forum to check where a user is logged in or not

<?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

 

 

Link to comment
Share on other sites

 

While your into sessions look at this example bit off a mind blower i say.

 

this is a session created with a array but now you got 3 session's set.

<?php session_start();

$x=array("john"=>"Has a big bike","paul"=>"has got a color tv","kevin"=>"has a motor bike");

foreach($x as $key=>$val){

$_SESSION['username'][$key]=$val;


echo " $key ".$_SESSION['username'][$key]."<br><br> ";

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.