View Full Version : wierd session error

08-02-2008, 01:30 AM
$token = rand(1,1000000000000);
$_SESSION['token'] = $token;

<a href='?action=get&&token=$token

When i try to compare these two values, it says they are in correct. So i echo'd them both out, and for some wierd reason the value in the session is always a - number, but the one in the variable is a positive number.

Whats' wrong :X?

08-02-2008, 02:11 AM
When I run your code I get a negative number for $token, so I removed one of the zeros from rand() and started to return positive numbers. Don't know if that helps or not...

Trevor (http://www.tkm-designs.com)

08-02-2008, 04:36 AM
The number 1000000000000 is too large to store in a signed integer, so it causes the number to wrap back to negative digits. The maximum number you can use is 2147483647, or getrandmax(). Windows only has enough space to handle a signed short, so its max is 32768 with getrandmax(). Use mt_rand to handle larger numbers.