Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I exclude a form from the session? #18

Open
RobertoVasquez01 opened this issue Feb 21, 2022 · 7 comments
Open

How can I exclude a form from the session? #18

RobertoVasquez01 opened this issue Feb 21, 2022 · 7 comments

Comments

@RobertoVasquez01
Copy link

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!

@RobertoVasquez01
Copy link
Author

Please help!

@thecodeholic
Copy link
Owner

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?

@RobertoVasquez01
Copy link
Author

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.

@RobertoVasquez01
Copy link
Author

Hello!. Does anyone have a good idea?

@thecodeholic
Copy link
Owner

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.

@RobertoVasquez01
Copy link
Author

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.

@RobertoVasquez01
Copy link
Author

I have a question.
If I use session to save some user preferences. Within my session management, when should I totally destroy the session?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants