phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Zend Framework Session: Automatic Expiration

Tag: framework, zend, zend framework, session, namespace   Category: PHP Framework
post: 24 Apr 2008 read: 684


Zend Framework Session Step By Step Tutorial - Part 6: We can set limited time for a namespace. For this feature, we called namespace expiration. Example, we want to count number of page request by a person in one minute. After 1 minute, he will be counted as new person. So, the code like this:

We try at loginform. Open UserController.php within application/controllers. Update loginFormAction():


  public function loginFormAction()
  {
	
    $ns = new Zend_Session_Namespace('HelloWorld');

	if(!isset($ns->yourLoginRequest)){
	    $ns->yourLoginRequest = 1;
	}else{
	    $ns->yourLoginRequest++;
	}
	
	$ns->setExpirationSeconds(60);
	 
    $request = $this->getRequest();      
	$this->view->assign('request', $ns->yourLoginRequest);
	$this->view->assign('action', $request->getBaseURL()."/user/auth");  
    $this->view->assign('title', 'Login Form');
    $this->view->assign('username', 'User Name');	
    $this->view->assign('password', 'Password');	
	
  }

You can set only at a particular key (e.g, yourLoginRequest):


$ns->setExpirationSeconds(60,'yourLoginRequest');


Series this article:
Zend Framework Session: Introduction
Zend Framework Session: Using Namespace
Zend Framework Session: Accessing Session Data
Zend Framework Session: Seing All Values at Namespace
Zend Framework Session: Locking and Unlocking Namespace
Zend Framework Session: Automatic Expiration

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting