Answer the question
In order to leave comments, you need to log in
How to find out the session id (I use dbsession) of a user in yii2 and how to work with expire values?
I use dbsession and see session values in db. Those. configured and configured correctly.
I want to know if the user is online. To do this, I want to take the expire value and compare it with the current time, if it is less than 24 minutes, then the user will be considered as an online user (with an error, of course, but still).
Faced difficulties, namely:
1. How to find out the user's session id by his login, for example?
2. Expire value is just an int number, for example 1427741261, what is this value and how to compare it with the current time?
Answer the question
In order to leave comments, you need to log in
1. Make your own session component, which writes the user ID in a separate field with an index. Override the writeSession method.
2. This is a UNIX timestamp. Compare as a number.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question