3

i nearly frustrated with how Zend handling session.

here is my case. i write a auth plugin that always check the the user credential utilize Zend_Auth. and when invoke hasIdentity function from zend auth, it will automatically start the session.

and the problem come when i have a long process that i need to execute. the session will lock the request until request completed. i try to release the lock by invoke Zend_Session::writeClose(false), so another request can be executed. but no way for me to start the session again.

is it a bad implementation if i try to resume stoped session?

there is only one session from the start until request execution ended?

thanks.

ps : i can do a little hack here. at the end of auth plugin i write a native php function (session_write_close) and if any controller need to use session again, i start it again with (session_start).

Charles
  • 50,943
  • 13
  • 104
  • 142
Jeg Bagus
  • 4,895
  • 9
  • 43
  • 54
  • Are you locking the request? Or is ZF doing it itself? – Jake N Sep 21 '10 at 14:08
  • 2
    ZF will automatically call session_start when i invoke hasIdentity() from zend auth class. and session_start will lock the session data until script finish. – Jeg Bagus Sep 21 '10 at 14:23
  • ¿Did you ever find a "good solution" for this? I'm running into the same issue. – GomoX Feb 29 '12 at 16:10
  • 1
    i think the only "other" solution is to use an "non locking" Session handler (Database? Memcache?) – opHASnoNAME Mar 01 '12 at 05:07
  • try this in bootstrap file register_shutdown_function(array('Zend_Session', 'writeClose'), true); – Pramendra Gupta Mar 08 '12 at 02:27
  • i just move long queue processing to another process. its bad approach to have php work too long for processing script. it will lock the thread, and webserver usually have limited thread to use. – Jeg Bagus Mar 09 '12 at 07:43

1 Answers1

1

The easiest solution to this problem is to use a database for session storage. No file locks to worry about (as ArneRie mentined).

Option 1

Use a common PHP extension and a tiny tweak to php.ini:

You can store them on a NFS export or recode the session_set_save_handler using a SQL backend for example. But there is no solution more efficient, more scalable, more performant and easier to deploy than using memcached…

Tutorial: http://www.dotdeb.org/2008/08/25/storing-your-php-sessions-using-memcached/

Option 2

The Zend way, through Zend_Session_SaveHandler_DbTable.

Examples: Zend - Storing Session data in a database

Community
  • 1
  • 1
Tim
  • 2,383
  • 1
  • 15
  • 19