Jump to content

Recommended Posts

Have you tried it? It should be possible as long as session_start() is used.

 

However, if it does not work right you may want to look into

 

www.php.net/serialize

and

www.php.net/unserialize

 

But try it first and see what happens.

Yes, you can send arrays through sessions. I created a shopping list for my wife and when she checks the items she wants to print, it creates an array and sets to a session. On the print page I take the session and break up the session into 3 arrays to make 3 colums on the page.

 

 

Here is where I grab the $_POST data, and set it as a session

 

<?php
$list_items= $_POST['list_items'];


if ($_POST['printit']){
session_start();  //start the session
$_SESSION['list_items']= $list_items; // set the session to the $_POST var above
echo'<meta http-equiv="refresh" content="0;URL='.$root.'shopping_list/printing.php" target="_blank" >';

};
?>

 

Here is where I take the entire list and break it up into 3 columns containing 45 items each

 

<?php
session_start();

$list=array_slice($_SESSION['list_items'],0,45);
$list2=array_slice($_SESSION['list_items'],46,45);
$list3=array_slice($_SESSION['list_items'],91,45);

// more code below here......
?>

 

 

Just remember to start_session() before you try to set the session vars.

 

Also you are creating a multi-dimensional array here as $_SESSION is an array as well

 

Nate

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.