phpeveryday.com

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


Zend Framework Login: Creating Logout

Tag: framework, zend, zend framework, authentication, Zend_Auth, logout   Category: PHP Framework
post: 22 Apr 2008 read: 2,854


Zend Framework Login System Step by Step Tutorial - Part 6: At protected page (in previous post), we had created a link to logout. This post talk about logout page.

First, create view for logout. Create a file named "logout.phtml" within application/views/scripts/user. Leave blank (because we don't want to show anything).

Then, we create a method for controller named logoutAction(). Open "UserController.php" within application/controllers. Add following method:


  public function logoutAction()
  {
    $auth = Zend_Auth::getInstance();
	$auth->clearIdentity();
	$this->_redirect('/user');
  }

We just use clearIdentity(). Then redirect page to another page (in this sample to user).



Series this article:
Zend Framework Login: Preparing Database
Zend Framework Login: Creating Form Login
Zend Framework Login: Creating Authentication
Zend Framework Login: Fatal error Cannot use object of type stdClass as array
Zend Framework Login: Protected Page
Zend Framework Login: Creating Logout
Zend Framework Login: Creating Switching for Front Page

| 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)
Joomla: Fast Road to Understand Component Programming
Chart: How to Build Cool Animation Real Time Chart
Email: Send Attachement Mail
SMS : Sending SMS with PHP and ActiveXperts (Part 1)

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


624
posting