-2

We have a website that is using a subdomain: blog.naturah.local. A proxy pass is set up for this, and it is pointong to: naturah.local/blog. We are setting gdpr cookies so that we provide the domain name in order to make the cookie available for the subdomain. When I have a look at the allowed cookied in chrome from blog.naturah.local, I can see the gdpr cookies in the list, the domain is naturah.local. But I can not access it from $_COOKIE['gdpr_privacy_bar'] it is not set, and the alow cookies bar is always showing under the subdomain. How can I get the values of cookies set under root doman from subdomain?

  <VirtualHost *:80>
      ServerName blog.naturah.local

      RewriteEngine on
      ProxyPassInterpolateEnv On

      RewriteCond %{REQUEST_URI} ^/public/.*$
      RewriteRule (.*) http://naturah.local/$1 [P]
      RewriteRule (.*) http://naturah.local/blog/$1 [P,E=proxy_pass_path:/blog]
      ProxyPassReverse / http://naturah.local/${proxy_pass_path}/ interpolate

</VirtualHost>

<VirtualHost *:80>
      DocumentRoot "d:/wamp/www/naturah/"
      ServerName naturah.local
      ServerAlias naturah.eva.wb
</VirtualHost>

Cookies in chrome's application tab

Header information

Eva
  • 173
  • 13
  • Please share your proxy setup. I’d probably start by checking what HTTP request headers the PHP script receives, to see if the cookie header did even make it that far. – 04FS Apr 24 '19 at 12:59
  • Please check this URL for more information : [Share cookie between subdomain and domain](https://stackoverflow.com/questions/18492576/share-cookie-between-subdomain-and-domain) – Siddhart hundare Apr 24 '19 at 13:58
  • I have added the virtual host setup – Eva Apr 25 '19 at 04:55
  • I have also added the cookies and header info that can be seen in chrome – Eva Apr 25 '19 at 05:17

1 Answers1

0

Ok, finally I have found tha way it works. I had to leave session domain blank in: session_set_cookie_params(), And I have set the cookie domain without the leading dot. It is a Kohana system runnig on php version 5.6.3, so there can be differences.

session_set_cookie_params(86400, '/', '', false, false);
setcookie('gdpr_privacy_bar', 1, time()+31556926, '/', $_SERVER['SERVER_NAME]);

Eva
  • 173
  • 13