Session information sharing on different subdomains

I am sharing sessions between two subdomains and I can see the member’s information in their different subdomains. If the member logs out, all subdomains are logged out. All is good so far.

However, for example, a.example.com the form information is POSTed to b.example.com. This form information is saved in the database, but the member’s ID is not registered. No information is registered to the database with the member. What could be the reason for this?

    ini_set('session.cookie_domain',
    substr($_SERVER['SERVER_NAME'], strpos($_SERVER['SERVER_NAME'], "."), 100));
    setcookie("MID", $_SESSION['uID'], 60 * 60 * 24 * 100, '/', '.example.com');
    session_set_cookie_params(60 * 60 * 24 * 100, '/', '.example.com', false, false);
    ini_set('session.save_path', $pathStorageMembers . 'sessions');
    ini_set('session.cookie_lifetime', 60 * 60 * 24 * 100);
    ini_set('session.gc_maxlifetime', 60 * 60 * 24 * 100);
    session_start();

You probably have a mistake in the php code, such as using one = (an assignment operator) in a conditional statement instead of two == (a comparison operator.). You would need to post all the code for the form processing page to get more specific help with what is wrong with it.

Also, why are you putting the form processing code on a different page than the form. This results in a poor User eXperience (UX), takes more code, and depending on how carefully you are passing information back to the form page, opens the site to Cross Site Scripting and Phishing attacks.

Sponsor our Newsletter | Privacy Policy | Terms of Service