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).

6
  • Are you locking the request? Or is ZF doing it itself? Commented Sep 21, 2010 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. Commented Sep 21, 2010 at 14:23
  • ¿Did you ever find a "good solution" for this? I'm running into the same issue. Commented Feb 29, 2012 at 16:10
  • 1
    i think the only "other" solution is to use an "non locking" Session handler (Database? Memcache?) Commented Mar 1, 2012 at 5:07
  • try this in bootstrap file register_shutdown_function(array('Zend_Session', 'writeClose'), true); Commented Mar 8, 2012 at 2:27

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.