ZF2-141: AJAX-ready sessions


Due to asynchronous nature of AJAX requests, it's probable for two requests of same client race each other for a session data. ZendFramework has already included the prefect implementation for JSON-RPC and XML-RPC servers. Any RPC server is useless without exclusive access to session data. I believe the following functionalities is what is missing right now in Zend_Session and/or Zend/Session classes:

  • Exclusive inter-request access to each session namespace.
  • Specifying the access type prior loading a namespace. Access types include: read-only, read & write. And for namespaces loaded as read-only, changing any part of session should throw an exception. I believe that it's obvious that read-only accesses share their locks while read & write accesses hold an exclusive one.

Suggestions for implementation: One can save each namespace in different file and lock it using flock when sessions are to be saved as files. As for the sessions in database, the database engine should lock the namespace record which MySQL supports.

Please let me know if I can be of any help. I'll be glad to know if my proposal is feasible or not.

Regards, Mehran Ziadloo


This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf2/issues/2450