Hi Aditya, usually, AFAIK, it is not logging out properly that causes an issue with this problem. The sesskey is not terminated properly, remains open and active when the student returns. So please make sure students log out properly.
For the rest, do you have access to the server? Or, do you have someone who has editing rights to the php.ini file, the Moodle database and Moodle codebase?
In the php.ini file, I would expect, there is a line which should read "session.auto_start=0" which would indicate the that the session is going to start at load. But, IMNAD, so am just guessing here. This may be hard coded somewhere in the million lines of code that make up Moodle.
In the database, the mdl_config table has a field called : sessioncookiepath. This is a value that can be set in the Moodle config page, if I am getting it right, which would be in the folder that all cookies are aimed at, the User's cookie path.
Also, this is from Ken Task, who is quite usually right with this kind of technical jibberish. :
If you have access to command line, try this:
First, take a look at the files contained in moodledata/sessions
ls /path/to/moodledata/sessions
The only reason for doing that is to see what's there now so that when you execute below one can tell it's working. ;)
Then
cd /admin/tool/task/cli
php schedule_task.php --execute=\\core\\task\\session_cleanup_task
That might take some time if there are sessions that need to be 'cleaned up' so be patient and let it run.
'spirit of sharing', Ken
He also suggests this should be run regularly.