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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:31:43+00:00 2026-05-31T16:31:43+00:00

I want to share my session variables in PHP using many subdomains. I have

  • 0

I want to share my session variables in PHP using many subdomains. I have that example :

  • example.com
  • subdomain1.example.com

I try to use the same session variables between the two domains. I already tested a lot of functions in PHP but nothing work. Here is my way to test :

On the example.com/page.php, I have that test :

echo '<pre>';
var_dump(session_set_cookie_params(0, '/', '.example.com')); 
session_start(); 
echo "Session ID : ".session_id()."\n";
$_SESSION['foo'] = 'bar';
print_r($_SESSION);

And on subdomain1.example.com/page.php, I have that one :

echo '<pre>';
session_set_cookie_params(0, '/', '.example.com');
session_start();
echo "Session ID : ".session_id()."\n";
print_r($_SESSION);

I can see that the session id is the same between the two pages, but session variables are impossible to read in subdomain1.example.com/page.php

I tested many functions, like set a name to the session, but with no more results.

Thank you.

  • 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-31T16:31:45+00:00Added an answer on May 31, 2026 at 4:31 pm

    The only way I can think of to do this would be to save the session data to a cookie, then open the cookie when the other domain is accessed. You can read how to do this here: http://www.depiction.net/tutorials/php/cookies-session-variables.php

    Out of curiosity, why do you want to do this?

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

Sidebar

Related Questions

I have a PHP page and I want to share some data between pages
Say I have the following interface that I want to share between my server
I have a single Rails 2.2.2 app that I want to 'share' with multiple
I want to share session cookie among domains. I have more than one domain:
I want to share my experience of using maven through a proxy. You would
This is the URL I want to share: http://mydomain.com/#url=http://stackoverflow.com Inside my site, I do
I've a small project that I want to share with a few others on
Is it possible to share a session between my PHP app on a subdomain
I am using PHP, for some reason and I want to switch sessions from
How can I print a list of session arrays with php? I have this

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.