Are sessions only kept alive each time you access a page with session_start();
or do other pages keep it alive too?
Example (with 30 minute
There is always a session cookie set in your browser whenever you access a page which has session_start()
. The cookie name will PHPSESSID
if the website is using PHP(although the name can be changed). This session cookie contains a session id which helps the browser to maintain that session with the server.
You can check manually by browsing any website which has your session and then delete your browser cookies, your session will be lost.
In your case both 1 & 2 are correct.
2 is correct because the user already has accessed a page which has session_start()
and your session id will be set for the next 30 mins and it will be present even if you accesse a page which does not have a session.
NOTE: But the page which you will be visiting if contains session_destroy()
, your session will be destroyed.