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?
Advertisement
Answer
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