php-mvc-framework
php-mvc-framework copied to clipboard
How can I exclude a form from the session?
I would like to load the CONTACT form and others, without creating an instance of the Session class. Does anyone have a good idea? Help please @thecodeholic!
Please help!
Sorry my friend your requirement is not very clear: and others - What do you mean in others?
Why don't you want to create instance of Session class? Can you provide more details?
Thanks for your reply. I was not very clear, I hope I am. Maybe I'm wrong because of the lack of experience in app development. But it seems to me that as long as a user does not identify himself in a web application, with his Username and Password, a session should not be created, session_start(). In this way. I suggest that some forms like CONTACT, LOGIN AND OTHERS, DO NOT use session_start().
In the framework, all ROUTEs create an instance of the Session.php Class and a session, session_start(), is also created.
For this reason I assumed that I shouldn't instantiate the Session.php class in some routes, but I'm really not sure about this solution. Any ideas from @thecodeholic creator, will be good, I appreciate it.
Hello!. Does anyone have a good idea?
Hello, IMO you are half right, half wrong. Technically you can skip session initialization, but why? what is the reason of not initializing session? Session can be used not only when user is authorized, but saving some preferences of the user. For example when user opens the site we might detect user's location based on IP address and save that in session, so that we don't have to detect every time user opens the page.
Complex and popular frameworks might have option not to initialize Session instance when not using and this can be implemented here as well, but you can to alter the core of this framework, which IMO is not necessary for this reason. Initializing session does not change anything.
Thank you very much. It has been of great help because it confirmed what was investigated. I will use the session to save the preferences of the users, visitors and authorized.
Thank you again.
I have a question. If I use session to save some user preferences. Within my session management, when should I totally destroy the session?