Forum Moderators: coopster
I have a problem with a session variable:
in my main php page I have the following code :
session_start();
if (!isset($_SESSION["rndOrderNR"]))
...
...
$_SESSION["rndOrderNR"]=rand(0, 999);
This put a random number in the session variable. And if I do an unset from an include page like:
unset($_SESSION["rndOrderNR"]);
session_destroy();
it even clears the session variable. but when I run my main php again to calculate a new random number, it radomizes the same number?!
in my php.ini I have: register_globals :off
Anyone who can help me?
Thanks!
The rand() function has had some issues so you may want to check the bug reports for your OS and PHP version. [bugs.php.net...]
I'm using php 4.3.4. But you're right, there seem to be some bugs with the rand() function. At least I know that's not a coding mistake of mine. Is there a simple way to solve this with srand() instead? Because at the site you refer to they talk about CVS or something. Meaning I have to compile things? Or perhaps upgrading to version 4.3.6? Never done an upgrade, can this cause many problems?
Is there a simple way to solve this with srand() instead?
It seems as that solution works for some folks. You could try it. There is an example in the thread provided (or one of the links from within that thread).
Out of curiousity, what operating system are you using?