phpeveryday.com

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


Zend Framework Session: Locking and Unlocking Namespace

Tag: framework, zend, zend framework, session, namespace   Category: PHP Framework
post: 23 Apr 2008 read: 374


Zend Framework Session Step By Step Tutorial - Part 5: Session namespaces can be locked. What's that mean? When a namespace session is locked, we can not update or delete value of session. it will be read-only.

We can use lock() to lock namespace. Then, if want to check whether locked or not, use isLocked(). Look this sample:


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

    if (!$ns->isLocked()) {
	  if(!isset($ns->yourLoginRequest)){
	    $ns->yourLoginRequest = 1;
	  }else{
	    $ns->yourLoginRequest++;
	  }
    }
	 
    $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');	
	
  }

To unlock, you can use unLock() method.


$ns= new Zend_Session_Namespace('HelloWorld');

// marking session as read only locked
$ns->lock();

// unlocking read-only lock
if ($ns->isLocked()) {
    $ns->unLock();
}



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
CAPTCHA - part 3 : "Are you human or ....?" (Build Your CAPTCHA)
Email: Send Attachement Mail

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


615
posting