Alternative to session_destroy (), without deleting variables

0

I'm working with php sessions, and I have a quick question to answer, but I'm not clear on the official PHP documentation.

What I want to do is that after starting a session (session_start ()), I close it, but without destroying the variable information.

There is some suitable function for this, or you would have to necessarily refresh the browser.

    
asked by Ruben-PX 05.01.2019 в 14:47
source

1 answer

2

I think what you're looking for is session_write_close () , which writes information session and ends it, so you do not have to wait for the script to finish, which would be when the session is closed by default.

  

File-based sessions (the default in PHP) block   the session file once a session is opened via   session_start () or implicitly via session.auto_start. While you are   locked, no other script can access the same session file   until it has been closed upon completion of the first run   script, or by calling session_write_close ().

     

This usually causes problems in those websites that perform   many AJAX requests and have multiple requests being used   the time The easiest way to deal with this is by calling   session_write_close () as soon as a change has been made   Required to the session, preferably before finalizing the script.   Alternatively, you could use a different session in second   flat that admits concurrence.

Source: link

    
answered by 05.01.2019 / 15:15
source