• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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