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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:20:37+00:00 2026-06-13T13:20:37+00:00

I am currently developing two web sites, and debugging them by connecting to localhost

  • 0

I am currently developing two web sites, and debugging them by connecting to localhost.

The first site is referenced with http://localhost/web1 and the second is referenced with http://localhost/web2.

I have created a login script for each in which three domain-specific session variables are set, e.g.:

  1. $_SESSION['web1_user']
  2. $_SESSION['web1_login']
  3. $_SESSION['web1_sessionID']

However, when I log in to both sites on the same browser, then log out of one site (which fires session_destroy(), I am automatically logged out of the second site as well.

Any ideas as to how I might resolve this problem would be very much appreciated. 🙁

  • 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-13T13:20:38+00:00Added an answer on June 13, 2026 at 1:20 pm

    Ahhh, the pleasures of shared hosting!
    The best thing to do is simply use a different browser for each site whenever you actually require being logged in to both sites simultaneously…

    To explain why this is important, you must understand the following, however:

    Session variables are stored on the server, with a keyed reference on the server and a cookie on your browser. Once you unset and destroy either of the two, a match can no longer be made – and your session is gone!

    session_start();
    session_unset();
    session_destroy(); 
    

    The above will kill all session variables linking the server to your browser (on the server side).

    The way to manage this easily is to make session variables into another set of arrays:

    $_SESSION["site1"] = array( $user_id, $session_id );
    $_SESSION["site2"] = array( $user_id, $session_id );
    

    You could of course make it fancy:

    $_SESSION['site3']['userID']    = 'someuserid';
    $_SESSION['site3']['sessionid'] = 'somesessionid';
    

    Then when you logout from site 1

    session_start();
    unset($_SESSION['site1']);
    

    In this case, you have created a separate session management system for each site (using a two-dimensional array, the top layer of which is keyed by your site’s identifier). This makes it so that each site manages a separate set of session variables – and when you destroy one, you do not touch the others.

    However, I realllllllllly recommend using different browsers instead (or in addition)…

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

Sidebar

Related Questions

I am developing a jQuery mobile web app, which currently has two pages. First,
Currently I'm developing two solutions (first for country A, second for country B), which
I am currently developing a jsp web application that maintains two clients of two
I'm new to magento. Currently i'm developing two ecommerce sites using multi-store option in
I'm currently developing a tutorial site for teaching the fundamentals of Web development (HTML,
Currently developing a PHP framework and have ran into my first problem. I need
I'm currently developing a web application based on jQuery Mobile. I would like to
I am developing a webpage at http://www.knowledgenation.us and currently I have roughly 500 posts
I'm working on a web site project that is currently tracked in svn but
I am currently in the process of developing a Web Service which should expose

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.