Jump to content

Recommended Posts

How can I create a session array populate it with only one item (id), and then add other  items without overwiring the original session?

 

foreach ( $_POST as $key) { echo $key; echo "<br>"; $_session['cart'][] = $key; }?>

    <?

// Attempt to add values into session array

echo '<pre>'; print_r($_session); echo '</pre>';

?>

 

This will take in the one bit of date but is overwritten if I add anything new to it, how can I increment the session array to hold more data (like new row in mysql).

 

The problem is because I could create a new mysql table and have a temporary cart, but flushing the temporary orders (not completed) order would be a pain so I thought it better to create a session array, is this good practice?

 

Cheers

Sarah

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

Ok cool, I understand that, thanks loanwolf, but how do I increment the new index?

 

This is the bit im having trouble with, as If i make the index a variable then it does not seem to work as IO dont know how to check if the index already exists. I want the index to be numerical eg:

 

$_SESSION['1'] = "foo";

$_SESSION['2'] = "bar";

$_SESSION['3'] = "!!!";

Link to comment
https://forums.phpfreaks.com/topic/150734-session-array/#findComment-791906
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.