phpeveryday.com

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


Zend Framework Session: Seing All Values at Namespace

Tag:    Category: PHP Framework
post: 23 Apr 2008 read: 259


Zend Framework Session Step By Step Tutorial - Part 4: This is a little tips to show all value at a namespace. As we know, session can have behavior like array. So, we can show values like array. Look this sample:

$ns = new Zend_Session_Namespace('HelloWorld');
foreach ($ns as $index => $value) {
  echo "ns->$index = '$value';";
}

Ok, try to test it. We have put session at loginform and userpage page. Now, we want to show request statistic for that page. Open your "UserController.php" within application/controllers. Add following method:


  public function statsAction()
  {
    $ns = new Zend_Session_Namespace('HelloWorld');
    foreach ($ns as $index => $value) {
      echo "ns->$index = '$value';";
	  echo "<br />";
    }

  }

Then, create a view for this action controller. Create a file named "stats.phtml" within application/views/scripts/user. Leave blank.

Ok, try to point your browser to http://localhost/test/zend/helloworld/web_root/user/stats. You may get such as:


ns->yourLoginRequest = '2';
ns->yourUserPageRequest = '7';

Values depend on number of visiting.



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