You only need to register the variable once when you initiate the session. Also as of php 4.1 I believe you do not have to register your session vars you can just acccess them like $_SESSION['counter']:
http://www.php.net/manual/en/ref.session.php Basically what I see you're doing is reregistering the variable on each page which initializes it as 0 and so when you do $counter++ you're always going to get 1.. Hope this helps! Rick "Dost thou love life? Then do not squander time; for that's the stuff life is made of." - Ben Franklin > From: "Jeff Sheltren" <[EMAIL PROTECTED]> > Date: Wed, 23 Jan 2002 12:31:49 -0800 > To: <[EMAIL PROTECTED]> > Subject: [PHP] More Fun With Sessions! > > Well, I was having problems getting sessions working at all on my FreeBSD > box, but they are now working... > But that leads me to more problems... > > For any others that might have a problem w/ FreeBSD, try setting the > referer_check to 0 > 'session.referer_check = 0' > > Once I changed that things seem to be working, ie. I can get a simple count > script to run with no probs, but here is where I come across a new problem. > This script works fine (it counts as I reload it): > <?php > session_start(); > session_register('counter'); > $counter++; > echo("You have visited this page $counter times."); > ?> > > What I am wanting to run on the site is a shopping cart app (along with some > other scripts that utilize sessions) that I wrote myself. Everything works > fine on my home linux box, but doesn't seem to be working on the FreeBSD > box. Maybe I am just not using sessions properly, but it is bugging me > because it works on the linux box... Here's an example: > > test.php: > <?php > session_start(); > session_register('counter'); > $counter++; > echo("You have visited this page $counter times.\n"); > ?> > <a href="test2.php">click here</a> > > test2.php: > <?php > session_start(); > session_register('counter'); > $counter++; > echo("You have visited this page $counter times.\n"); > ?> > <a href="test.php">click here</a> > > Shouldn't this hold the same counter variable for both pages? It works fine > on my linux box, but on the FreeBSD box, $counter is always 1. I think that > if I could get something like this script working, then the shopping cart > would also work. Sorry for the long message! Any help would be greatly > appreciated. > > Jeff > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]