![]() |
Quote:Why are we telling you this? Because it is likely that after trying to find the reason for your performance issues, you may conclude that locking is the issue and therefore look into how to remove the locks …https://www.codeigniter.com/user_guide/l...sions.html in MyController.php PHP Code: class LearnSession extends BaseController result: PHP Code: session()->get() array (3) What does session()->close() do? What does method close() mean? What is the difference between close () and remove()?
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. If you use AJAX then you should do a session_write_close when finished with your sessions. Hope that clarifies it for you. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
maybe you need to execute destroy()?
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).
(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. @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. 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?
@Renta Ardhana, The best way to understand things like the session methods etc, is to view the source files
in .\system folder. If you look at the methods you should be able to understand what the developers are doing and how the methods work. When I first started using CI 1.6.2 back in 2014 I sat down on the weekends and just kept reading the CodeIgniter Users Guide over and over to get a very good under standing of what was going on etc. I also skimmed through the .\system files to understand what they were doing. Just my personal opinion. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(07-18-2024, 02:53 AM)InsiteFX Wrote: @Renta Ardhana, The best way to understand things like the session methods etc, is to view the source files @InsiteFX thanks for sharing your experience. |
Welcome Guest, Not a member yet? Register Sign In |