Welcome Guest, Not a member yet? Register   Sign In
How to use session()->close()?
#5

(This post was last modified: 07-18-2024, 01:08 AM by Renta Ardhana.)

(07-17-2024, 10:22 PM)InsiteFX Wrote: 1) session_close is checking to see if your in environment testing mode then it will return else it will issue a session_write_close.

2) Difference is that close is doing what I said above. remove just removes session data by item or array.

..

Hope that clarifies it for you.

@InsiteFX thank you, I got the difference now. 1. Closing the Session "process" vs 2. Removing the data/item/array.

(07-17-2024, 10:22 PM)InsiteFX Wrote: If you use AJAX then you should do a session_write_close when finished with your sessions.

Does it mean that session()->close() can only improve performance for AJAX?

What about in the context of non-AJAX requests (normal page reload)? Can session()->close() also improve performance in this case; as per documentation said that?

(07-17-2024, 10:43 PM)ozornick Wrote: maybe you need to execute destroy()?

@ozornick thank you, I will destroy session when user logout, right?

 At first, I thought close() was a new feature in CI4 to enhance the destroy method, but it gues I was wrong."

(07-17-2024, 11:40 PM)kenjis Wrote: close() persists the session data (e.g. it saves in the session file or the database) and closes the session.
But it does not change the existing session data (after all, $_SESSION in PHP).

I understand now what session->close() do (and don't).

As stated in the documentation, it says that closing the session is a best practice for improving performance related to locking/unlocking the session. Does this also apply to non-AJAX requests, regarding @InsiteFX comment above?
Reply


Messages In This Thread
How to use session()->close()? - by Renta Ardhana - 07-17-2024, 10:02 PM
RE: How to use session()->close()? - by InsiteFX - 07-17-2024, 10:22 PM
RE: How to use session()->close()? - by Renta Ardhana - 07-18-2024, 12:52 AM
RE: How to use session()->close()? - by ozornick - 07-17-2024, 10:43 PM
RE: How to use session()->close()? - by kenjis - 07-17-2024, 11:40 PM
RE: How to use session()->close()? - by InsiteFX - 07-18-2024, 02:53 AM
RE: How to use session()->close()? - by kenjis - 07-18-2024, 03:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB