Re: Very simple session question
| From: | tedd | Date: | Tue, 27 May 2008 01:49:25 +0000 |
| Subject: | Re: Very simple session question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-274709@lists.php.net to get a copy of this message | ||
At 10:16 PM +0100 5/26/08, John Allsopp wrote:
Hi I've gone bozzeyed, so I've a simple question for you. I open session_start() as the first thing, on each page. I set a session variable using, for instance, $_SESSION['ACCOUNTemail'] = $email; The next program, when I var_dump($_SESSION), it shows an empty array. That program does run session_start() too. What's obviously wrong, or what's my most likely cause? Cheers JJ: That should work. Are you sure you're using <?php session_start(); I forgot the () one time and it had me going for a while. Also, try this (it should work): ======= Page 1 <?php session_start(); // page1.php $num = isset($_SESSION ['num']) ? $_SESSION ['num'] : 0; $num = 1; $_SESSION ['num'] = $num; echo($num); ?> <form action="page1.php"> <input type="submit" value="Goto the next page"> </form> ======= Page 2 <?php session_start(); // page2.php $num = isset($_SESSION ['num']) ? $_SESSION ['num'] : 0; echo($num); ?> <form action="page1.php"> <input type="submit" value="Goto the last page"> </form> Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com