weemikey Posted May 30, 2007 Share Posted May 30, 2007 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; } Quote Link to comment https://forums.phpfreaks.com/topic/53618-session-question/ Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 make sure you have session_start(); at the very top of the page. www.php.net/session_start Quote Link to comment https://forums.phpfreaks.com/topic/53618-session-question/#findComment-265094 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.