Jump to content

session


fareedreg

Recommended Posts

I would like to pass one variable value to another form. Please help me out.. I am using session_start() in first.php and trying to access it on another second.php. BUT NO SUCCESS. Please help me out

or give me example.

 

//first.php

session_start();

 

$chkmemid=$memid;

$session[$chkmemid] = $memid;

 

 

 

 

//second.php

$dd=$chkmemid;

 

 

IS THE ABOVE MENTIONED CODE IS RIGHT?

Link to comment
https://forums.phpfreaks.com/topic/186871-session/
Share on other sites

you set a session variable using $_SESSION['varname'] = 'your value';

 

you retrieve it in the same manner, $foo = $_SESSION['varname'];

 

The underscore and case are important.

 

A quick read up on these superglobals from the manual would help you.

Link to comment
https://forums.phpfreaks.com/topic/186871-session/#findComment-986856
Share on other sites

Yes, it's important that you're spelling the super-global correctly. It is also important that you place session_start at the top of every page that you wish to access the $_SESSION super-global from. Example:

 

page 1:

session_start();
$_SESSION['something'] = 'val';

 

page 2:

session_start(); // You need this
echo $_SESSION['something']; // val

Link to comment
https://forums.phpfreaks.com/topic/186871-session/#findComment-986874
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.