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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:47:56+00:00 2026-05-25T09:47:56+00:00

I am storing all sessions in MySQL via session_set_save_handler , but now I’d need

  • 0

I am storing all sessions in MySQL via session_set_save_handler, but now I’d need to use sessions across subdomains on localhost. Does that even work on localhost?

I already added:

ini_set('session.cookie_domain', '.localhost');

to my code, but that didn’t seem to solve the problem either, probably because I am running the code on localhost. Or is there any workaround to be able to use it on localhost?

BTW, I am using XAMPP on Win7.

Example:

http://localhost has the session_id 2oog13m67rr1sd1gk94lbf1he2

and

http://sub.localhost has the session_id 3vr0pdqljothmmf4btlenvk047

So, I guess you just can’t use .localhost for the session.cookie_domain.

  • 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-25T09:47:56+00:00Added an answer on May 25, 2026 at 9:47 am

    Since you are already making up domain names, I suggest you don’t reuse the top level domain. Either use one you own or invent a brand new one. The name localhost already has a well-defined meaning and that can lead to issues like the one you are facing. Particularly, browsers impose restrictions based on TLD’s so you are not able to, e.g., set a cookie .com or .co.uk. I’m pretty sure that localhost has its own rules as well in most browsers.

    Update: If you are using Chrome, see this bug report resolved as invalid:

    You can only set domain cookies for registry controlled domains, i.e.
    something ending in .com or so, but not IPs or intranet hostnames like
    localhost

    Related question: Localhost Cookie

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

Sidebar

Related Questions

I am well aware of PCI Compliance so don't need an earful about storing
All, I'm reading a csv file and adding the data to a MySQL DB
I'm using sessions to receive my info from my database table... But I'm not
I'm building a webapp. HTML+AJAX <--> PHP <--> MySQL; very traditional. What I need
I am using a MySQL DB and a Java JDBC client to access it.
For a web application, I decided to store the sessions variables into a database.
I'm trying to use polymorphic_on on a python class with several inheritances: engine =
I'm trying to use mysql_real_escape_string() to secure a log in form. Using this code:
I'm trying to submit a page onto itself by using php echo $_SERVER['PHP_SELF']; but
I have now changed my login system from session_register() to this: UPDATE : <?php

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.