简体   繁体   中英

Unique identifier for user in browser without login

I operate a small shop online and I would like to allow users to buy stuff even if they do not have an account. For that, I need to connect a basket of selected items with a user. I thought using the ip address, but I noticed that it is actually not that easy to get the ip address. I am sure people have encountered that problem before? What is the best solution? thanks carl

thanks for the replies. Following the hints given above I solved the problem by generating a session id. In flask that's done using

import uuid
session['uid'] = uuid.uuid4()

Flask also seems to have a 'sid' element in the session object (session.sid), which apparently does the above automatically... but that did not work for me?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM