Jump to content


[PHP] Multiple Random Values, on Same Request

  • Please log in to reply
1 reply to this topic

#1 Brian Miller

Brian Miller

    Neowinian Senior

  • Joined: 15-December 10

Posted 09 October 2013 - 03:31

I have a Web Application that is running a custom REST Server. Every API request gets passed through this server. With that being said, when I refresh a page on my Web Application 5 simultaneous AJAX requests are being made. I noticed when I call something like a date(), time(), microtime() or rand(), they all return the same value for EACH request for "Random".
For example, here's the code that is being executed:
echo 'RANDOM!: ' . rand(5, 10000);
Here's the response:
Response -> RANDOM!: 4288
Response -> RANDOM!: 4288
Response -> RANDOM!: 4288
Response -> RANDOM!: 4288
Response -> RANDOM!: 4288
To clarify again, each request above is an AJAX call. I've never really encountered an issue like this before. Also, adding sleep() didn't have any affect. Can anyone help?

#2 The_Decryptor



  • Tech Issues Solved: 4
  • Joined: 28-September 02
  • Location: Sol System
  • OS: iSymbian 9.2 SP24.8 Mars Bar

Posted 09 October 2013 - 05:21

Are you seeding the random number generator?

Click here to login or here to register to remove this ad, it's free!