I am beginning to learn php. I have a question regarding sessions.
Right now, I know that session_start()
creates a session variable.
What I don't know is, when I access the session I created, do I need to use session_start()
again?
If yes...
Why is this? Because I already created a session and I wonder why it wouldn't last the entire browsing session.
because what i understand from it is, that it is going to create a new session.
No:
session_start()
creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie.http://php.net/session_start
Each new page you visit is an entirely new context for PHP. session_start
allows you to reestablish a previous context/session/data.
The session_start function tells PHP to enable session tracking. It doesn't wipe out the session created by a previous page. You must call session_start() before you'll have access to any variables in $_SESSION.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With