fareedreg Posted January 1, 2010 Share Posted January 1, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/186871-session/ Share on other sites More sharing options...
ToonMariner Posted January 1, 2010 Share Posted January 1, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/186871-session/#findComment-986856 Share on other sites More sharing options...
Alex Posted January 1, 2010 Share Posted January 1, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/186871-session/#findComment-986874 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.