PhpRiot
Follow phpriot on Twitter
Sponsored Link
Download Article
Download this article or the entire “Zend Framework 101” series with all listings and files.




More information
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

Related Books
PHP Solutions: Dynamic Web Design Made Easy

PHP Solutions: Dynamic Web Design Made Easy

This is the second edition of David Power's highly-respected PHP Solutions: Dynamic Web Design...

PHP for the World Wide Web, Third Edition

PHP for the World Wide Web, Third Edition

With PHP for the World Wide Web, Third Edition: Visual QuickStart Guide , readers can start from...

Zend Framework 101: Zend_Session

Other Zend_Session Functionality

In addition to what's been covered so far in this article, there are some other advanced features that can be used with Zend_Session. This section shows introduces you to these features and provides a link for more information about the feature.

Storing Sessions in a Database

By default, PHP stores session data on the filesystem of the server. You can change this so session data is stored in a database. The database must be a connection made using the Zend_Db component. You can then make use of the Zend_Session_SaveHandler_DbTable class with the Zend_Session::setSaveHandler() method.

Tip: If you don't use Zend_Db for accessing your database (or you want to save session data using some other method), you can create your own save handler by implementing the Zend_Session_SaveHandler_Interface interface.

Storing session data in your database is useful in a load-balanced environment, where subsequent user requests may be handled by different front-end servers (all sharing the same database server).

For more information on saving session data to the database, refer to http://framework.zend.com/manual/en/zend.session.savehandler.dbtable.html.

Session Value and Namespace Expiration

You can make values in a session namespace (or an entire namespace) automatically expire after a set period of time. The time can be measured either in seconds or “hops” (that is, you can make a value only be set for the specified number of subsequent page requests).

For details on automatic expiration of session values refer to http://framework.zend.com/manual/en/zend.session.advanced_usage.html#zend.session.advanced_usage.expiration.

In This Article