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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:48:54+00:00 2026-06-09T08:48:54+00:00

I am having problems with keeping a session active in the home directory of

  • 0

I am having problems with keeping a session active in the home directory of my website.

I have a file named login.php where the session is set. Then if I navigate to index.php and do print_R($_SESSION), it prints it. Then I go to gallery.php and it is gone. Same is true in reverse order: it appears if I go to gallery.php first, then disappears in index.php.

I’m thinking it might be the php.ini related.

edit:
Ok I figured out it was an included file that was causing this, its included on both pages, called ‘nav.php’

<?php 
session_start();
$logout = intval($_GET['logout']);
if(isset($logout)){
session_destroy();
//header('Location: '$_SERVER['PHP_SELF']);

}
echo '<a href="/index.php" title ="home" class="navbutton">home</a>

<a href="/gallery.php" title ="gallery"class="navbutton">gallery</a>
 <a href="/info.php"title ="info"class="navbutton">info</a>

<a href="/contact.php"title="contact"class="navbutton">contact</a>';

if(isset($_SESSION['names']) || isset($_SESSION['guestlogin'])){echo '<a href="'.$_SERVER['PHP_SELF'].'?logout=1" title="logout"class="navbutton">logout</a>';
echo'<a href="/gallery" title ="gallery"class="navbutton"> test gallery</a>';

}
else{echo '<a href="/login" title="login"class="navbutton">login</a>';
}
echo'<a href="/blog"title ="blog"class="navbutton">blog</a>

<a href="/prints"title ="prints"class="navbutton">prints</a>';?>

could it be b/c it has session_destroy in it or something? Also are all included files supposed to have a session_start on them?

  • 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-09T08:48:57+00:00Added an answer on June 9, 2026 at 8:48 am
    $logout = intval($_GET['logout']);
    if(isset($logout)) {
      session_destroy();  
    } 
    

    Do you see a problem here? $logout always has some value. No matter what the value is. So isset($logout) is always TRUE. Change it to:

    if(isset($_GET['logout']) && $_GET['logout']) {
      session_destroy();  
    } 
    

    This will logout user if he followed URL with logout=1 in query string.

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

Sidebar

Related Questions

I'm having problems embedding php inside an html file. I first ran in to
I am having a problem keeping my keyboard active when I validate input and
Im having problems with a method in a class file: public static function getPageLeft($pid)
Im having problems with classpaths. I have used them before with import but I'm
I am having problems with SQL Server dropping a connection after I have dropped
I'm having a problem with keeping a JBoss server running. Here's the command I'm
Having problems with a small awk script, Im trying to choose the newest of
Having problems iterating. Problem has to do with const correctness, I think. I assume
Having problems with the combining of two statements in a controller. Both statements work
Im having problems with displaying ONLY some elements ONLY on print page. For example

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.