note 110649 added to function.session-start

From: Date: Sat, 17 Nov 2012 14:30:47 +0000
Subject: note 110649 added to function.session-start
Groups: php.notes 
Request: Send a blank email to php-notes+get-192015@lists.php.net to get a copy of this message
When you have an import script that takes long to execute, the browser seem to lock up and you cannot access the website anymore. this is because a request is reading and locking the session file to prevent corruption. you can either - use a different session handler with session_set_save_handler() - use session_write_close() in the import script as soon you don't need session anymore (best moment is just before the long during part takes place), you can session_start when ever you want and as many times you like if your import script requires session variables changed. example <? session_start(); //initiate / open session $_SESSION['count'] = 0; // store something in the session session_write_close(); //now close it, # from here every other script can be run (and makes it seem like multitasking) for($i=0; $i<=100; $i++){ //do 100 cycles session_start(); //open the session again for editing a variable $_SESSION['count'] += 1; //change variable session_write_close(); //now close the session again! sleep(2); //every cycle sleep two seconds, or do a heavy task } ?> ---- Server IP: 91.199.167.223 Probable Submitter: 82.157.123.135 ---- Manual Page -- http://www.php.net/manual/en/function.session-start.php Edit -- https://master.php.net/note/edit/110649 Del: integrated -- https://master.php.net/note/delete/110649/integrated Del: useless -- https://master.php.net/note/delete/110649/useless Del: bad code -- https://master.php.net/note/delete/110649/bad+code Del: spam -- https://master.php.net/note/delete/110649/spam Del: non-english -- https://master.php.net/note/delete/110649/non-english Del: in docs -- https://master.php.net/note/delete/110649/in+docs Del: other reasons-- https://master.php.net/note/delete/110649 Reject -- https://master.php.net/note/reject/110649 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192015) next »