Hi how can I retrieve a value from SESSION. Store that value in a variable. Decrement by one the value of that variable and store it back into SESSION.
What I'm trying to do is assume I have a $_SESSION["counter"] with the value of 30
I would like to store that value in a variable when the USER enters the program
Decrement the value by 1 when a user presses a button (it calls a function)
and continue to use the same value (decrement by 1) when the user presses the button again
I have ---> $tok = $_SESSION["counter"]
when the program starts
$_SESSION["counter"] = $tok -= 1;
when the user presses the button, and it calls a function (I have $_SESSION ["counter"] = $tok -= 1; inside the FUNCTION)
My problem is that when the user enter the php program, it retrieves a variable of 30, when he presses the button, it does store the value of 29 in $_SESSION["counter"] when the user presses the button, but if the user re-presses the button, it stores the SAME VALUE of 29
I have tried to retrieve the $_SESSION... value INSIDE the function, so I can retrieve the current value from 'counter', but it gives me an error.
Thanx for ur help