Jump to content

Storing variables in a session


denhamd2

Recommended Posts

Hi,

 

I'm wondering could you help me... I'm sending a number of variables between 2 pages using the form GET method, and I want to store them in a session. The variables are basically called after dates and they will equal "yes" if the user has selected them.

 

Eg. they might have selected 3 tickboxes in page 1:

 

$07042007 = yes

$18042007 = yes

$22042007 = yes

 

which get sent to page 2 via the URL

 

is there any way of storing these in session variables of the same names?

Link to comment
https://forums.phpfreaks.com/topic/45580-storing-variables-in-a-session/
Share on other sites

if(isset($_GET)){
         foreach($_GET as $key => $value){
                $_SESSION[$key] = $value;
          }
}

echo "<pre>";
print_r($_SESSION);

foreach($_SESSION as $key => $value){
.........................
..........................

I think you will get this
}

list out the varibles you do not want to set in session of previous page which are fixed and few. like this

 

$un_nec_varible = array('monthsubmit','anyother');

if(isset($_GET)){
         foreach($_GET as $key => $value){
               if(!in_array($un_nec_varible,$key)){ 
                      $_SESSION["DATA"][$key] = $value;
               }
         }
}
echo "<pre>";
print_r($_SESSION["DATA"]);

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.