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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:14:28+00:00 2026-05-28T15:14:28+00:00

I am currently using the Tonic PHP framework to build a RESTful application (

  • 0

I am currently using the Tonic PHP framework to build a RESTful application ( http://peej.github.com/tonic/ ) and am having an issue that I cannot figure out how to get around with redirecting a user after having someone log out. The strange part is that logging in works just fine.

My basic code works list this: when a user goes to log in, they fill out a simple form a press a submit button to do a post request to the same page the form is on. ( website.com/login ) The post handling code looks like this:

public function post( $request )
{
    if( isset( $_POST[ 'username' ] ) && $_POST[ 'username' ] === 'username' &&
            isset( $_POST[ 'password' ] ) && $_POST[ 'password' ] === 'password' )
        {
            $_SESSION[ 'loggedin' ] = true;
            $response = new Response( $request );
            $response->addHeader( 'Location', '/' );
            return $response;
        }
        else
        {
            $response = new Response( $request );
            $response->addHeader( 'Location', '/login/fail' );
            return $response;
        }
}

(the current code is just a temporary thing so I can test functionality) This will properly set the session variable and redirect back to my index page, with my PHP code outputting all the proper menus and things for being logged in.

The problem I then have, is with the button directly inside the menu bar on my web page for logging out. I tried two methods for this with neither working: a simple anchor tag with an href to the page webspace.com/logout, and putting a form with just a restyled submit button in the menu to look like a normal link, using post as the method to the same page. Both of them have this code:

public function post( $request )
{
    $response = new Response( $request );
    $response->code = Response::MOVEDPERMANENTLY;
    $response->addHeader( 'Location', '/' );
    $response->body = "<b>Succesfully logged out!</b>";
    $_SESSION[ 'loggedin' ] = false;
    return $response;
}

(or at least variations on that, trying various things) When this code is used from the menu bar, either through an anchor tag or a form submit button, it will go to the /logout page and just stay there, outputting any body text if it exists. The PHP code checking if the user is not “logged in” doesn’t even trigger, leaving the menu bar in a state of looking like you are currently logged in, even though the moment you go to another page it changes to the logged out code, meaning you have successfully logged out already. I’ve tried various things, and just going there through the browser bar directly will work fine, and not setting the session variable will also cause it to work fine. (as far as I’ve seen) I have no idea what is going on. Thank you for any help in advance.

  • 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-28T15:14:29+00:00Added an answer on May 28, 2026 at 3:14 pm

    Never mind, I realized the problem (which was just me being stupid): I was doing output to the page BEFORE issuing a Location header, causing it to be ignored by the browser. Shuffling order of operations around a bit on my main page fixed the problem.

    Let this be a warning to all: make sure you issue headers before echoing any code out to the browser, no matter what. In my case, this required me to do all the handling code for the current URI before my HTML code, then sending the output from the request to the browser in the correct location.

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

Sidebar

Related Questions

Im currently using vs2008 with asp.net mvc framework for web development. Im missing a
I have a collection of PHP classes that can be instantiated traditionally using constructors.
Currently using System.Web.UI.WebControls.FileUpload wrapped in our own control. We have licenses for Telerik. I
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
Currently using Google Analytics as a supplement to our paid tracking software, but neither
I'm currently using VS2005 Profesional and .NET 2.0, and since our project is rather
I am currently using Windows Server 2008 Standard and have several Hyper V machines.
I am currently using the following command to upload my site content: scp -r
I'm currently using the awesome attachment-fu plugin for a Rails app, but as a
My company is currently using Sage MAS as their ERP system. While integrating our

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.