Ok, I've just started looking into sessions and was messing around with simple stuff, like incrementing the user's session value every time they requested the page, but I came across the following problem:
I was trying to do the following
It quickly became apparent that the value of the counter only reflected the value of the session variable, meaning I can't increment the counter variable.Code:session_start(); session_register('counter'); $counter = $_SESSION['counter']; // Try incrementing $counter now that it points to the session variable $counter++; echo $counter;
The way to do it would be:
So I was just wondering if there was a way of transferring the value to the $counter variable, instead of merely reflecting what is held in the session.Code:$_SESSION['counter']++;
In its current state I can only echo the $counter, but I can't add anything to it, or perform any operations on it.
Any way to get around this?
Thanks,
Jack.



Reply With Quote
).

Bookmarks