1

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?

Anish
  • 768
  • 3
  • 12
  • 34
  • You don't need to do anything special. As soon as some time has passed - the session is removed by GC automatically – zerkms Jun 16 '12 at 10:51
  • @ Zerkms please can you give me a good link where I can learn this because i am new to this – Anish Jun 16 '12 at 10:53
  • 1
    http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes – zerkms Jun 16 '12 at 10:53

1 Answers1

0

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.

Harald Brinkhof
  • 4,375
  • 1
  • 22
  • 32