session_disconnect()
| From: | Alain Williams | Date: | Mon, 16 May 2011 13:37:53 +0000 |
| Subject: | session_disconnect() | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-52389@lists.php.net to get a copy of this message | ||
I am working on some AJAX callbacks. These need to open the session, get hold of stuff in $_SESSION
and that is it ... they won't be changing the session data. The trouble is that because the
session file is locked the Asynchronicity of AJAX is reduced a bit, especially if some of the
server side calls need a lot of work.
May I suggest:
session_disconnect();
This would, in effect, close the session file but leave $_SESSION. This would be easy to implement,
just call the second callback to session_set_save_handler().
This is NOT quite the same as a session_end() function since that would presumably write the
(changed) contents of $_SESSION back to where ever. With session_disconnect() any changes made
to $_SESSION would be lost regardless of them being made before or after the call to
session_disconnect().
Another way of doing this would be to add an optional boolean argument to session_start() which
would load $_SESSION and then disconnect. This is more intrusive in that changes to any user
open functions (of session_set_save_handler()) would be needed. It might be a tiny bit faster
or neater.
I do not know how much of a speed improvement this would make to what sort of AJAX applications.
Regards
--
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>