B
B
BonBon Slick2017-07-04 13:16:37
Sessions
BonBon Slick, 2017-07-04 13:16:37

How to implement the collection of statistics on sessions?

In settings of sessions put use of the database. I want to keep statistics of sessions, every time someone visits the site, the record goes there, like a log. However, I don't understand how to arrange it.
This is not just a registration, where he made a registration event, and indicated the creation of a new user in the event.
it is necessary to separate the logic, users who are registered and those who are not. Naturally, it will not work here to set up an event, every time someone visits such and such a URL, create a session, because they can stupidly update the page, and thereby clog the session table. And the user can go to another route (), where there is no session creation event, and then it will not be in the statistics. In which it will be necessary to calculate who, when, from where came to the site. Nothing comes to mind how to do it right.
Can you please tell me how to manage the session mechanism for statistics? How does the algorithm work in general?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Semyon Beloglazov, 2017-07-05
@BonBonSlick

Create a middleware that will run on every http request. You already write the logging logic in it, there is nothing complicated here. You can find out if a guest is a guest or not using isGuest() (or something like that, I don’t remember exactly, googled it).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question