Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Why isn't the php session working on the subdomains?  (Read 3269 times)

0 Members and 1 Guest are viewing this topic.

Bannana97

    Topic Starter


    Intermediate
  • Owner of HerbertsWorld Corporation
    Why isn't the php session working on the subdomains?
    « on: May 09, 2010, 10:07:39 AM »
    Hi. I am making a website builder, and for some reason, when I make a session on site.com, then the session doesn't work on builder.site.com.

    The code I am using in front of every page is:
    Code: [Select]
    session_set_cookie_params(1440, "/", ".red-host.org", false, false);
    session_start();
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");


    And the code that makes the session is:
    Code: [Select]
    session_set_cookie_params(1440, "/", ".red-host.org", false, false);
    session_start();
    $_SESSION[$_SESSION_NAME]="$_POST[username]";

    Any advice or help would be appreciated. Thanks.
    Thanks
    Bannana97

    kpac

    • Web moderator
    • Moderator


    • Hacker

    • kpac®
    • Thanked: 184
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 7
    Re: Why isn't the php session working on the subdomains?
    « Reply #1 on: May 09, 2010, 10:41:03 AM »
    It's because the session_start() function uses a cookie for authentication, and the cookie is only stored for the builder.site.com path.

    Bannana97

      Topic Starter


      Intermediate
    • Owner of HerbertsWorld Corporation
      Re: Why isn't the php session working on the subdomains?
      « Reply #2 on: May 09, 2010, 10:53:18 AM »
      Oh, so how can I fix this issue?
      Thanks
      Bannana97