php - SESSION cannot be used when the queue is executed asynchronously, so can I still use the queue when logging in?
怪我咯
怪我咯 2017-05-16 13:05:36
0
1
350

SESSION cannot be used when the queue is executed asynchronously, so can I still use the queue when logging in? If so, how can I deal with the corresponding relationship between cookies and sessions?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
刘奇

Can I still use the queue when recording?

Login is usually a synchronous process. Using a queue is not impossible, but it will increase complexity.

The synchronous login process is to read the database, determine the correct account and password, and set up the session, which can be completed in one HTTP request.

Changing to asynchronous, I can only think of the following method:

  1. Client generates random token

  2. The client sends the token, account number, and password to the server

  3. The server records this token in redis and has not logged in successfully

  4. The server puts the token, account, and password into the queue for processing

  5. Queue processing, if the account is correct, the token in redis is marked as successful, otherwise it is marked as failure

  6. During the process of server and queue processing, the client keeps using another interface to poll to see if the token login is successful. If successful, all subsequent requests will bring the token, otherwise the client login fails.

So the synchronous login process should be completed as soon as possible, and some operations required after login (sending email notifications, etc.) should be queued instead of the entire login process.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template