6

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%'
Thomas Jensen
  • 2,138
  • 2
  • 25
  • 48

1 Answers1

1

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.

Marcel Dumont
  • 1,217
  • 1
  • 11
  • 17
  • 1
    This is the same answer as in this question: http://stackoverflow.com/questions/138670/how-unique-is-the-php-session-id Does this mean that Laravel session ID == PHP session ID and that the answer given in 2008 is still valid? – Thomas Jensen Dec 14 '14 at 19:43
  • It uses similar principles, but Laravel has it's own session handler, see for example https://github.com/laravel/framework/issues/293 – Marcel Dumont Dec 14 '14 at 19:45