How to assign random session key to visitor who visit the website in PHP?

Kashmiri Ammar :

I have not much experience in PHP. i am creating a shopping store in PHP where a visitor can add item into cart without creating account (as guest). so i just want to assign him a unique id or key for add to cart process. so how can i assign him a random key when he visit the website?

DevDonkey :

another approach: PHP already creates a unique id for each session, this is how sessions work. You could use this to identify the user.

You can get this from the session with session_id().

You can also set a session id with this, but please read the first comment on the document page

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=302419&siteId=1