I have a website where the user starts on one page and then moves to a second page. The first page initializes and adds values to a counting variable, which I then want to be able to be displayed on the second page. I know to use a session, but I am wondering how I should properly end the session--do I end it on the first page, or the second page? Do both pages need to begin with session_start()
?
Yes. Both must use session start. The variable you are talking about is basically termed cookies. The variables will be shared throughout the browser sessions.
To be a little bit more precise, The function session_start(); will make the Global $_SESSION
available for the current active page
So you have to put session_start on each page than require a variable to stay on your session
You'll also probably want to use session_destroy(); and session_unset(); at the last page your users will have to visit
I hope I helped you !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.