Re: session prob
| From: | Steve Keller | Date: | Mon, 05 May 2003 21:38:02 +0000 |
| Subject: | Re: session prob | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146455@lists.php.net to get a copy of this message | ||
At 5/5/2003 08:02 AM, Geoff O'Callaghan wrote:
<?php session_start(); session_register('count'); $count++; print "You have been to this web page $count times<p>"; ?>According to the script you've posted, you're never putting the session count into $count, and never putting $count back into the session data. You seem to be assuming that $_SESSION['count'] and $count are the same variable, they are not, and incrementing $counter does not affect the session variable. What you should be doing is grabbing the session value into a new variable, incrementing it, and then putting it back. <? session_start(); if(session_is_registered('count')) { $myCTR = $_SESSION['count']; } else { session_register('count'); } $myCTR ++; $_SESSION['count'] = $myCTR; ?> <HTML headers> <? echo "<p>You have been to this web page {$myCTR} times.</p>"; ?> -- S. Keller UI Engineer The Health TV Channel, Inc. (a non - profit organization) 3820 Lake Otis Pkwy. Anchorage, AK 99508 907.770.6200 ext.220 907.336.6205 (fax) Email: skeller@healthtvchannel.org Web: www.healthtvchannel.org