N
N
nepster-web2014-12-16 16:08:00
Yii
nepster-web, 2014-12-16 16:08:00

Yii2 session in database, how to determine userId?

I want to store sessions in the database, for this I used:
https://github.com/yiisoft/yii2/blob/master/framew... The
question is, do I need to add my userId field to the table?
For example, if you need to log out a certain user or check whether he is online or not?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Vapelnik, 2014-12-25
@dvapelnik

I don't think this needs to be done with the session table since a session is not just about user authorization, although it is used by user authorization. and the presence of a session file does not yet mean that the user is online. he could leave, but the session lives in view of the fact that session.gc did not kill
the online monitor of the user, whether I would have done something differently: somehow monitor the user and save his status. either query with ajax, or add a filter to all controllers, or somehow hang it on sockets. but the ratio (user_id, session_id) to store in a separate table
I would

  1. did not change the table structure for the cache
  2. i would store (user_id, session_id) in a separate table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question