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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:52:31+00:00 2026-06-05T04:52:31+00:00

I have a website. People can login it on here sub.domain.com If they login

  • 0

I have a website. People can login it on here

sub.domain.com

If they login here, the session will do its job and user will be logged in. On any page at sub.domain.com, the session value be will returned so it will work fine.

But site can also be reached from http://www.sub.domain.com . When user logins at sub.domain.com, the session value is empty at http://www.sub.domain.com.
I mean if user logs in at sub.domain.com,
When he navigates to http://www.sub.domain.com, site will say ‘please login’, but user was already logged in at site without ‘www’.
Hope it was all clear, 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-06-05T04:52:33+00:00Added an answer on June 5, 2026 at 4:52 am

    Add in your main script at the top, before session_start.

     ini_set('session.cookie_domain', '.domain.com' );
    

    If you running PHP with suhosin enabled, try disabling there settings too

      ini_set("suhosin.session.cryptdocroot", "Off");
      ini_set("suhosin.cookie.cryptdocroot", "Off");
    

    Source PHP bug tracker

    Thanks to @RandomDave

    You could dynamically determine the domain from $_SERVER[‘HTTP_HOST’] so you don’t have to hard-code the domain name

      ini_set('session.cookie_domain', strtolower(substr($_SERVER['HTTP_HOST'], 0, 4)) == 'www.' ? substr($_SERVER['HTTP_HOST'], 3) : '.'.$_SERVER['HTTP_HOST'] );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an website where people can place a vote like this: http://mysite.com/vote/25 This
I have people posting their website address but variations are posted such as: theirsite.com
I have website where users can login with their Facebook account. I am using
I have a website where people can upload 30+mb of data in a single
I have a website where people can contact each other, and quite often people
Here's what I've done. Its a website with a login page. Once logged in,
I have a log-in system, where people can login with an username. I really
I have a DotNetNuke website that by default people use anonymously. When they want
I have a blog. I like people to login to my website and mark
Which system is more natural rating for users? I have a website where people

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.