Forum Moderators: coopster
I have a login script which uses sessions.
I have a charting app which uses sessions.
How does PHP handle this? Does it create three different sessions or is everything handled by the one session file? In other words, is it working like magic and I don't need to worry about it.
What I'm confused with is that at the start of the login script there is a start_session() and other session related stuff. On logout, the session is destroyed.
Now does this affect the start_session() of the other scripts?
1. session_start() -> if none session, then one is created (id - random, not repeating alfanumeric string), one file is created in secured place (without http access)
2. all variabled are stored in that file
3. you can store and retrieve the variables by super global $_SESSION
4. session id is passed via session cookie or url www.example.com/index.php?SID=987asdjhg98764kjhga9876...
Therefore to your questions:
- hard to say. There may be one session for all three, or each destroys previous session. (There can be only one session at a time!)
- start_session() should be in every file, unless you use session.auto_start = 1, if you don't have it then the actual session will be destroyed. Don't use in includes.
- session_destroy() will destroy that session - you loose any information stored there.
Use session just to pass relevant data concerning that particular user.
hope this helps
Michal CIbor
If first the login script initiates session file.
Second, the user access the message board
Third, the user generates a chart
Fourth, the user logouts of the message board (which has a session_destroy()
Then what happens to the login and if he wants to produce another chart?
-Once you are logged in you have 1 session.
-all the scripts use that session (message board and chart)
-user can creates as many charts as he wishes
-after logout user can't do anything but log in.
If the scripts are written properly you do not have to worry about anything:)
Login is shown only when the session is destroyed, so after log out, not after making chart
Hope this will help
Michal Cibor
PS. To specify more clearly if it will work I need the script (without html)