简体   繁体   中英

How unique is the session ID in Laravel?

I am keeping track of article hits by storing each page view in a table along with the session ID, I then use the session ID to weed out ( count(distinct session) ) multiple hits in the users session lifetime.

But how unique is the Laravel session ID? Should I also take other things into consideration, such as the time to avoid incorrect grouping?

Update: I adjusted my SQL to take the date into account as well:

select count(distinct session, DATE(created_at)) as aggregate from `article_views` where `article_id` = ? and `agent` NOT LIKE '%bot%'

Session ID is pretty unique, it can be duplicated, but the probability is very low. If you have a website with a fair traffic, it may happens once in you web site life, and will just annoy one user for one session. This is not worth to care about unless you expect to build a very high traffic website.

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