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 8538181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:05:11+00:00 2026-06-11T11:05:11+00:00

I am using zend framework. I have built a simple login screen. when the

  • 0

I am using zend framework. I have built a simple login screen. when the user logs in, I want to set a session and then in the init function of the member area controller its meant to check for the session and grant access, else, redirect to login screen.

I have set my login controller like so, this check the username and password and sets the session:

if (isset($_POST['loginSubmit']) && $form->isValid($_POST)){
            $inputtedUsername = $_POST['username'];
            $inputtedPassword = $_POST['password'];
            if ($inputtedUsername == $username && $inputtedPassword == $password) {
                $loggedIn = new Zend_Session_Namespace('loggedIn');
                $loggedIn->success;
                $this->_forward('index', 'home');
            } else {
                echo 'invalid';
            }
        }

I have a home controller, which only logged in users should be able to see, so in the innit function I have:
$loggedIn = new Zend_Session_Namespace(‘loggedIn’);

if (isset($loggedIn->success)) {
            echo 'success';
        }else{
            $url = $this->view->url(array(
                'controller' => 'index',
                'action' => 'index'));
            header('Location:' . $url);
        }
    }

when i log in, using the correct credentials, it redirects me to login screen as stated in the else function.

what am i doing wrong?

  • 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-06-11T11:05:12+00:00Added an answer on June 11, 2026 at 11:05 am

    First your use of Zend_Session_Namespace is incomplete (you never assigned a value to the namespace):

    $loggedIn = new Zend_Session_Namespace('loggedIn');//here you created a namespace
    $loggedIn->success;//here you created a key in that namespace with no value
    

    The way your code seems to be structured any value assigned to $loggedIn->success would return true, so maybe try :

    $loggedIn = new Zend_Session_Namespace('loggedIn');//here you created a namespace
    $loggedIn->success = true;
    

    While this might fix your current issue, I want to suggest you take a look at two Zend components that can really help with authentication and authorization.

    The first is Zend_Auth, a component that deals with application authentication and will also help handle user session persistence. Rob Allen has a tutorial to help get you started.

    The second is Zend_Acl, The Access Control List component, deals with authorization, who has access to what. A place to start with Zend_Acl

    • 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
We have a site built in Zend Framework and we're using the Zend Soap
Hi I have a web service built using the Zend Framework. One of the
I have a website built on Zend Framework. I want to run the site
I have a application built using Zend Framework. I have decided to go with
I have a PHP MVC application using Zend Framework. As presented in the quickstart,
i have a problem with upload mutilply files using zend framework on server actually
I'm trying to develop a site using Zend Framework, but i have a problem:
I have got access_token. Using zend framework. I have obtained token for multiple permissions.
I have a Zend Framework project using version 1.10.8 with Doctrine 1.2.4.I use Zend_Auth

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.