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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:36:03+00:00 2026-05-20T19:36:03+00:00

I have observed my php application behaving rather strangely on the server that it

  • 0

I have observed my php application behaving rather strangely on the server that it is running on. When a user first visits the application, and clicks on a link with an absolute path, the session data is cleared.

I have recreated the problem as simply as possible. The code can be found below.

I have solved this problem by removing all absolute links in my application, I am simply looking for an explanation of this behavior.

To recreate the problem:

  1. click ‘login’
  2. click ‘relative link’ and observe that the session still has the ‘logged_in’ variable set
  3. click ‘absolute link’ and observe that the session data appears to be missing
  4. click your browser’s back button and observe that the session data has returned
  5. click ‘absolute link’ and observe that the session data is missing again
  6. click ‘home (relative link)’ and observe that session data is missing this time
  7. click ‘login’ to reset the session data
  8. click ‘absolute link’ again and observe that the session data was not cleared this time

Some important things to note:

  • This is not a problem locally on my
    mac running MAMP with php 5.3.2,
    but is a problem on a server with
    php 5.2.14 and a different server running 5.3.2
  • clicking the absolute link, and then the relative home link without login prevents the problem from ever occurring once you do log in.
  • once the problem is solved by the method just mentioned, it can only be recreated by navigating to a different domain, clearing your browser’s cache and navigating back. Clearing the cache without leaving the page will not work.
  • this is also a problem if using a absolute path when redirecting using header(‘Location: …’)

index.php:

<?php
    session_start();

    print_r($_SESSION);

?>

    <br/><a href="http://www.myserver.org/page.php">Absolute link</a>
    <br/><a href="page.php">Relative link</a>
    <br/><a href="login.php">Log in</a> | <a href="logout.php">Log out (reset session)</a>

page.php:

<?php

    session_start();
    print_r($_SESSION);

?>
    <br/><a href="index.php">Home (relative link)</a>

login.php:

<?php
    session_start();
    $_SESSION['logged_in'] = true;

    header('Location: index.php');

logout.php:

<?php
    session_start();

    $_SESSION = array();
    session_destroy();

    header('Location: index.php');
  • 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-20T19:36:04+00:00Added an answer on May 20, 2026 at 7:36 pm

    Solved:
    Thanks to Nouveau for pointing out that a cookie can only be used for one domain and The Scrum Meister for asking if I always access the site with a www.

    The problem was created by starting at http://myserver.com and following the link to http://www.myserver.com

    The Session was initialized for http://myserver.com and then again for http://www.myserver.com

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

Sidebar

Related Questions

We have Core2 machines (Dell T5400) with XP64. We observe that when running 32-bit
I have created two simple files in php. first file (i.e. input.php ): Created
I have a big xhtml document with lots of tags. I have observed that
I have used $_SERVER['HTTP_REFERER'] variable in my application (used PHP). On Firefox above variables
I have an application at http://www.facebook.com/LovingPets?fbhref=index.php&app_page=1&v=app_190518734309657&sk=app_190518734309657#!/LovingPets?fbhref=treats.php&app_page=1&v=app_190518734309657&sk=app_190518734309657 . I keep getting problems with trying to
Have you ever seen any of there error messages? -- SQL Server 2000 Could
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
Have a n-tire web application and search often times out after 30 secs. How
I'm working on one application ( using PHP, javascript ). Below is the short
I am writing a fairly complex PHP applications where a single user action can

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.