Answer the question
In order to leave comments, you need to log in
Unkillable PhP sessions, how is that possible?
A session on my site starts with these lines of code:
<?php
ob_start();
session_start();
session_destroy();
session_unset();
Answer the question
In order to leave comments, you need to log in
I see two solutions:
1. Why not just remove the parameters responsible for authorization in the session? Logging out of an account can be done by simply removing the user_id parameter from your session.
2. Why don't you consider self-implementation of sessions? Choose a high-speed storage like MongoDB (note that this is the local file system by default) and manage your session parameters (including the lifetime) yourself. Before each request, you do some kind of Session-> check () in which you request parameters and update the user session lifetime in the database, and if it didn’t work, then create a new record with a tricky name through Session-> start () like what does UUID and give it to the client as a COOKIE. On your "exit" simply call Session->destroy() and explicitly send a request to delete your record from the database.
This is a bicycle, of course, but you will immediately solve not only the problem of session destruction, but also prepare a solution for scaling to several servers.
What happens to the session cookie? Because the session is matched to a specific browser by the cookie, use_trans_sid is disabled by default.
What is the problem? Browser not clearing cookies on close? It is not obliged to do this, but it is not forbidden to delete it by the standard.
The session lives for a long time - how long? How much gc_maxlifetime is specified? Do you understand that this is the time after which the garbage collector can delete the session, and not the guaranteed maximum lifetime? That this time is counted from the last reversal to session?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question