V
V
Vladimir Maltsev2015-04-02 21:19:51
PHP
Vladimir Maltsev, 2015-04-02 21:19:51

Cross-domain COOKIES installation via PHP on NGINX. Where to dig?

I recently started working on NGINX servers - I dig to the best of my knowledge ...
There are two domains domain1.mysite.com and domain2.mysite.com
On the domain1.mysite.com domain I set COOKIE:

setcookie( 'cookie' , 'hi' , time()+3600 , '/' , '.mysite.com' , false , true);

According to the principle of Apache, the cookie should go to all subdomains of mysite.com, but on NGINX it is installed only on domain1.mysite.com.
nginx configuration
server {
    listen       80 default_server;
    server_name  www.mysite.com;

    charset utf8;
   
    ...
    

    location / {
        root   /home/www;
        index  index.php;
        if (!-e $request_filename) {
      rewrite ^/(.+)$ /index.php?uri=$1 last;
      break;
    }
        
        location ~ \.php$ {
            fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            #   
            fastcgi_connect_timeout 3000;
            fastcgi_send_timeout 3000;
            fastcgi_read_timeout 3000;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k; 
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;
            fastcgi_intercept_errors on;      
            include fastcgi_params;
            client_max_body_size       10m;
            client_body_buffer_size    128k;
            expires off;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
       }
        
    }

    #error_page  404              /404.php;
    error_page   500 502 503 504  /50x.php;
    location = /50x.html {
        root   /home/www;
    }

    
}

What am I doing wrong or what am I not doing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Leonid Sysoletin, 2015-04-06
@sysoletin

Well, actually, the behavior of cookies should not change from the name of the server.
Look in the browser what and how it is put, and how it differs from what you are trying to put, you need to dance from this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question