Jump to content

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

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.