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

  • Home
  • SEARCH
  • 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 6894931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:50:39+00:00 2026-05-27T06:50:39+00:00

I have created a login form. It works fine, but it goes back to

  • 0

I have created a login form. It works fine, but it goes back to the logged in page if the user clicks back button after they log out.
When I tried something to stop it, the index page stopped working. It shows problem loading page error.

I have done this in my index page to avoid the user not to go back to logged in session but now the index page itself doesn’t work.

if (!isset($_SESSION['user'])) {
    header('Location:index.php');
}   

logout.php:

session_start();#This will start the session
session_unset(); #Session_unset and Session_destroy
session_destroy();#Will remove all sessions.

header("location:index.php");#This code will sen du back to the index page

Once the user logs in the user logs in to this home page. I have added session like this:

session_start();

$user = $_SESSION['user'];

Please correct me where I am wrong. The problems I am facing are:

  1. to make my index page display
  2. avoid user going back to their logged in session after logging out
  • 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-27T06:50:39+00:00Added an answer on May 27, 2026 at 6:50 am

    This could help people who will be looking for the same issue..!

    To avoid the back button getting into your home page after logging out.paste the below code after altering with your session key and variable

    <?
    
    session_start();
    
    $user = $_SESSION['user'];
    
    if ($_SESSION['user'] == ""){
    
      header('LOCATION:index.php');
    
    }
    ?>
    

    This will go to the home page as the browser redirects and then the homepage will direct back to the index page if the session is empty (note that the session will be destroyed once the user clicks logout)

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

Sidebar

Related Questions

i have created one login and register view in that view after login user
I have the following function in ZF1 login controller and works fine but cannot
I have the page below, everything works fine... Except that after I click the
I have a login page which works fine. I would like your help for
I have created Login forms and registration forms for a website. The form is
I have created login page forced login in several pages. Now i need to
I have created a User called Student and Teacher that can login into the
I've created a login page and in the db table i have a field
I have already created a custom layout for my Magento theme which works fine.
I have created a loginform that is displayed on the front page. Everything works

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.