Sign in to follow this  
Followers 0
Brian Miller

[PHP] Multiple Random Values, on Same Request

2 posts in this topic

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);

die;

 

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?

Share this post


Link to post
Share on other sites

Are you seeding the random number generator?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.