I am working on a "online examination" project. I created a session variable for timer and set it to 1800 seconds which is equal to 30 minutes.
I used a ajax call to get the session value and every thing works fine but, whenever I reload the browser (or) close the browser and opens the same page ,its not resuming from the last where I leaved.
How can I do that ?
I AM USING PHP for server side scripting.
THX IN ADVANCE.
Session get destroyed on closing the browser.But reloading the page should get the value from the browser(without closing the browser).Check sessionStorage object in the client side for your session data.
If you don't want to loose the timer value on browser restart.save the timer value in the cookie
make sure your start the session from backend i.e. session_start() and save your varible
You need to control two things that controls session's lifetime.
session.cookie-lifetime : The lifetime of the cookie, which by default is 0, which means the cookie is destroyed when the browser is closed. You can set a longer lifetime by increasing this variable.
session.gc-maxlifetime : This option checks the last access time of the session data, so it is relative to the time the session data was last used.
For example if you need cookie time for a year:
ini_set('session.cookie_lifetime', 60 * 60 * 24 * 365);
ini_set('session.gc-maxlifetime', 60 * 60 * 24 * 365);
session_start();
*Use your own time for your purpose.
Im assuming your online examination
is not all static html, right..