Question

For eg:

http://example.com/login

Here is my site once I logged inside and uses User page example.com/user and when I log outside www.example.com/logout then the session is to be closed.

But if User did not logged in when anyone uses example.com/user the details should not come because I want the sessions to be closed and it should affect different browsers also.

How can it be done?

Was it helpful?

Solution

Zend session management has the option to expire namespaces by 'hop' or time-based, you can also write lock the session via Zend_Session::writeclose or destroy it using Zend_Session::destroy() (ref: http://framework.zend.com/manual/en/zend.session.global_session_management.html)

destroy():

destroy(bool $remove_cookie = true, bool $readonly = true) Zend_Session::destroy() destroys all of the persistent data associated with the current session. However, no variables in PHP are affected, so your namespaced sessions (instances of Zend_Session_Namespace) remain readable. To complete a "logout", set the optional parameter to TRUE (the default) to also delete the user agent's session id cookie. The optional $readonly parameter removes the ability to create new Zend_Session_Namespace instances and for Zend_Session methods to write to the session data store.

writeClose():

writeClose($readonly = true) Shutdown the session, close writing and detach $_SESSION from the back-end storage mechanism. This will complete the internal data transformation on this request. The optional $readonly boolean parameter can remove write access by throwing an exception upon any attempt to write to the session via Zend_Session or Zend_Session_Namespace.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top