I sorted out this problem now Here was my soloution. if ($host ~* www(.*)) { set $host_without_www $1; } add_header Set-Cookie "logged_in=1;Domain=$host_without_www;Path=/;Max-Age=315360000"; Posted at Nginx Forum: https://forum.nginx.org/read.php?2,269189,269190#msg-269190