0

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.

Jenz
  • 8,280
  • 7
  • 44
  • 77
Dasari Vinodh
  • 103
  • 2
  • 14

3 Answers3

1

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

Nilesh
  • 41
  • 2
  • 5
  • how to check session storage object in client side i am new to this please explain me little in detail ... – Dasari Vinodh Feb 13 '14 at 05:12
  • Use inspect element in chrome.Go to resource tab and check session storage tree on right side.There should be your session variable – Nilesh Feb 20 '14 at 19:15
0

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.

newTag
  • 2,149
  • 1
  • 22
  • 31
0

Store the start time of the test in your database.

Im assuming your online examination is not all static html, right..

Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106