Jump to content

session start


jimfog

Recommended Posts

As far as I know, session start goes to every page the user might or might not be logged in. Does that include also the page where the signup or login form is located? Let us assume for now, that the form action are in a different page-both for the login form and the sign up form.

Link to comment
Share on other sites

If a script is included from a script with session_start() , no. Else, yes. EDIT: Do your diligence. You'll cause an error when you try to start a session in a session.

Edited by niche
Link to comment
Share on other sites

this has been answered already in different thread. the rule of thumb is where you will need to work with $_SESSION array you will need to start it. if you need to show the login panel to only the user who are not signed in then you will need to start the session cause you will check the authentication is session. same goes for sighn up page. if you dont want to let any sighned in user enter in sighnup page (show sighn up page only to guest or logout user), you will like to check its authentication and do action depends on that. so it is all depend on how you are going to use it.

Link to comment
Share on other sites

this has been answered already in different thread.
Yes I know, in the other thread though, this was not the main issue of discussion-other was.the rule of thumb is where you will need to work with $_SESSION array you will need to start it.
if you need to show the login panel to only the user who are not signed in then you will need to start the session cause you will check the authentication is session. same goes for sighn up page. if you dont want to let any sighned in user enter in sighnup page (show sighn up page only to guest or logout user), you will like to check its authentication and do action depends on that. so it is all depend on how you are going to use it.
And to avoid confusion...sure we are going to put session start in the page where the form is, even if the form action is in a different page? I want to stress the above.
Link to comment
Share on other sites

And to avoid confusion...sure we are going to put session start in the page where the form is, even if the form action is in a different page? I want to stress the above.
The HTML and PHP layers have nothing to do with each other. The form's action is part of the HTML layer.If in the PHP layer, you're using the $_SESSION variable, you need to use session_start() somewhere before that, regardless of the HTML (so yes, even if there's an action attribute to a different page).
Link to comment
Share on other sites

Now it is more clear-I just now want to work with code and see it from a practical standpoint. I maybe post some code later-here, or I might open a new topic, but for now I got the answer I was searching for.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...