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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:08:15+00:00 2026-05-31T22:08:15+00:00

This question is generally phrased as How to share cookies across multiple subdomains and

  • 0

This question is generally phrased as “How to share cookies across multiple subdomains” and the answer is generally to use the leading dot like so

setcookie( 'id', 0, time()+30*3600, '/', '.example.com' );

which means that the cookie is available to all subdomains of example.com. However, the / path I suspect adds the constraint that all subdomains must be physically under the same tree. The PHP documentation states

path

The path on the server in which the cookie will be available on. If set to ‘/’, the cookie will be available within the entire domain. If set to ‘/foo/’, the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.

Is it possible to share cookies if one has two (Apache) Virtual Hosts set up with document roots at, for example

  • http://www.one.example.com → /var/www/example1
  • http://www.two.example.com → /var/www/example2
  • 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-31T22:08:17+00:00Added an answer on May 31, 2026 at 10:08 pm

    Yes it will work.

    The path segments of the cookies are based on the URI.

    www.one.example.com and www.two.example.com both have / as the URI. The cookie doesn’t have anything to do with where the virtual host resolves to.

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

Sidebar

Related Questions

How many indexes should I use? This question has been asked generally multiple times,
This question made me curious. Questions like this always get answers like It's generally
This seems like a simple question to ask but, is it generally a good
This is a general question, not related to a particular operation. I would like
This question is for experienced Unix/Linux developers. If you have found that you like
While this question more generally has been looked at here: Exporting R tables to
Generally this question comes from Eclipse suggesting to add a serial version UID on
My answer for a recent question about GOTOs and tail recursion was phrased in
I've seen this question asked a few ways and the solutions are generally for
Now, I know this question is very opinion oriented because people generally design their

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.