WoHe Posted February 6, 2017 Share Posted February 6, 2017 I was wondering if there is any way to set unique values to each cookie. I want to use these cookies on my website to see if the visitor has already visited my website once, but without asking any information from them. This way I want to store this unique value in my database each time someone opens my website, and I will be able to see if there have been - for example - 20 different visitors in the past month, or if the same person has visited my website 20 times. All my code is already written and working, I only need a way to set a different unique value to each cookie I set. Link to comment Share on other sites More sharing options...
Ingolme Posted February 6, 2017 Share Posted February 6, 2017 A timestamp will give you a unique value unless two users appear at the same second. Get the timestamp by using PHP's time() function. If one second is not precise enough, there's microtime() the gets microsecond precision, pretty much guaranteed to give two users a different value even if they visit the site at the same instant. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now