Tom
Tom

Reputation: 159

session_id() in PHP

I am just trying the session_id function in PHP and I thought that it was unique for each machine that used the website? However, my flatmate and I have the same session_id for on two separate machines. I'm just using session_id() to create the session - am I doing it correctly?

Upvotes: 2

Views: 394

Answers (3)

Zachary Scott
Zachary Scott

Reputation: 21172

Another idea is to store a value in the Session.

Upvotes: 0

Pekka
Pekka

Reputation: 449415

You are missing the () in your session_id call.

Also remember that you need to call session_id() before session_start() if you want to use it to set a specific session ID. From the Manual:

If id is specified, it will replace the current session id. session_id() needs to be called before session_start() for that purpose. Depending on the session handler, not all characters are allowed within the session id. For example, the file session handler only allows characters in the range a-z A-Z 0-9 , (comma) and - (minus)!

Upvotes: 1

Joel
Joel

Reputation: 16655

Try creating your session like they do here

Upvotes: 1

Related Questions