|
Posted by Erwin Moller on 11/24/05 11:19
jkmambo@gmail.com wrote:
> Session data is getting lost in PHP version 4.4.1 which used to work in
> version 4.3.3
>
> The code is similar to the one below
>
> Assume the file is called count.php which requires a parameter
> productid;
>
> session_start();
> if (!isset($_SESSION['countAccess'])) $_SESSION['countAccess'] = 0;
> else $_SESSION['countAccess']++;
>
> echo $_SESSION['countAccess'];
>
>
Why don't you use {} to mark your logical blocks?
This is PHP, not python. ;-)
Like:
session_start();
if (!isset($_SESSION['countAccess'])) {
$_SESSION['countAccess'] = 0;
} else {
$_SESSION['countAccess']++;
}
echo $_SESSION['countAccess'];
> if I call the script with a parameter for example
> count.php?productid=78
>
> when I press refresh button $_SESSION['countAccess'] does not get
> incremented but if I call it without the parameter,
> $_SESSION['countAccess'] gets incremented.
That ?productid=78 has nothing to do with the SESSION.
It will appear in $_GET, not $_SESSION.
So this is very surprising.
Do you have more code, without {}, that might interfere?
If yes: fix it, and if the problem persists, show us the code.
> I am also losing data if I call another script.
>
> Does anyone know what's going on here?
>
> Thank you
Regards,
Erwin Moller
[Back to original message]
|