• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

PHP cookie across domain and subdomain

P

PlymWS

Guest
Hi,

I have Plesk 9.3 on a new server. I have a domian (domin.com) setup and a subdomain (sub.domain.com) setup as another domain rather than as a subdomain of the original. This allows me to specify a separate IP address for the subdomain and use 2 SSL certificates, one for the domain, one for the sub domain.

I am unable to use the sub.domain.com sookie to verify a session from domain.com Both domains are hosted on the same server and write their files to the same place.

I have tried chmod 777 the session files because the domains are controlled by a different user due to Plesk restrictions but this doesn't help.

I have also tried setting the session domain in php.ini as .domain.com but this also doesn;t help.

Anything else I can try ?
 
The issue you describe is not specific to Plesk - cookies cannot be accessed across domains.

In PHP you should be able to set the cookie with the domain in the form of ".domain.com" and this will allow the main site, and subdomains to access the cookie.

There is a section on the PHP site relating to this, specifically a section relating to setting the domain:

http://php.net/manual/en/function.setcookie.php

Paul
 
i have a similar issue and i would say it is related to plesk,
This code

<?php
ini_set('session.cookie_domain', '.domain.com' );
$some_name = session_name("domain");
session_set_cookie_params(0, '/', '.domain.com');
session_start();

makes problems go away in servers with no plesk,
but problem remains in server with plesk

surprise!

so please what is wrong in plesk configuration to interfere with session communication between subdomain and domain?

thank you
 
Back
Top