Jump to content

Recommended Posts

Hi all! I was pointed to the SESSION array by AndyB (thanks) to deal with some temp storage but now I have another question. I'm making a contact manager with checkboxes to select email addresses. There will be multiple pages that a user might visit while selecting these addresses. I need to store all of them in a big CSV. So I've created a session and a new variable to store the email addresses. I check to see if the session variable is set and add a comma, then the address. Or if the session variable isn't set I create it and add the email address. However I'm not getting the variable to stick around. I go to the page, select my emails, echo them to the screen and all's well. If I deselect all the addresses and just choose one, ONLY that one email address gets echoed back. If I understand how this is supposed to work, this should just KEEP adding addresses to my list until I reset or kill the session. Am I wrong in this understanding? Does the SESSION only apply to the current php script? Any advice would be great. Here's the code! Thanks a million!

 

// for each element in the array, do something
foreach($emails as $value) {

// if we already have an exportemails, add a comma and the email address
// otherwise just add the email

if(isset($_SESSION['exportemails'])){
		$_SESSION['exportemails'] = $_SESSION['exportemails'].",".$value;
	} else $_SESSION['exportemails'] = $value;
}

Link to comment
https://forums.phpfreaks.com/topic/53618-session-question/
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.