Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6140605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:08:23+00:00 2026-05-23T18:08:23+00:00

I am using PHP and Zend Framwwork for developing web apps, and i want

  • 0

I am using PHP and Zend Framwwork for developing web apps, and i want to implement login and logout concept in my application.In first step I create the auth adapter that is working well and authenticating the users.
There is a menu bar in the application where i have an anchor tag for login. After clicking the login link the login page appears.
Now my question is, I want that when the user login with his/her valid credentials, then the login text in menu changes to logout and when user logout it changes back to login.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:08:23+00:00Added an answer on May 23, 2026 at 6:08 pm

    For such task, I have profileLink view helper that checks if a user is logged or not, and displays appropriate message:

    /**
     * ProfileLink helper
     *
     * Call as $this->profileLink() in your layout script
     */
    class My_View_Helper_ProfileLink extends Zend_View_Helper_Abstract {
    
    
         /**
         * View instance
         *
         * @var  Zend_View_Interface
         */
        public $view;
    
    
        public function profileLink()  {
    
            $baseUrl = $this->view->baseUrl();
    
            $auth = Zend_Auth::getInstance();
    
            $html = '<a href="'.$baseUrl.'/login">'. $this->view->translate('Login') .'</a>';
    
            if ($auth->hasIdentity()) { 
                // here have to make amendments to what you have 
                // in your identity.
                $identity = $auth->getIdentity();                        
                $fname = $identity->property->nickname; 
                $url = $this->view->baseUrl('/user');
                $fnameLink = "<a href=\"$url\"/>$fname</a>";
                $html = $fnameLink . ' <span>|</span> <a href="'.$baseUrl.'/logout">'
                    . $this->view->translate('Logout') . '</a>' ;
            }   
    
            return $html;
        }
    
    
         /**
         * Get Zend_View instance
         *
         * @param Zend_View_Interface $view
         */
        public function setView(Zend_View_Interface $view) {
            $this->view = $view;
        }
    
    }
    

    Whit this, in the layout.phtml I just have:

    <?php echo $this->profileLink(); ?>
    

    The view helpers is modified version of one that I found somewhere in the net ( i don’t have a link to the original version).

    Hope this will be useful to you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I have a PHP Web application built using Zend Framework and MVC with
I want to write a php application using Zend Framework 2 (just the beta
I am developing an application to manage a law office using zend framework 1.10,PHP
I am developing a web application with Zend Framework, and I am using JQuery
I'm using PHP Zend framework for my web application. When users register, I send
I am developing a web application using zend framework. For select statements I have
I have a PHP MVC application using Zend Framework. As presented in the quickstart,
I am using the Zend library's XML RPC Client in a PHP application to
Part 1 I want to build a PHP Zend Framework application that users can
I'm developing PHP apps that leverage several frameworks (though not the Zend Framework yet...)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.