note 1743 modified in function.setcookie by imajes

From: Date: Sat, 06 Apr 2002 21:55:49 +0000
Subject: note 1743 modified in function.setcookie by imajes
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-28790@lists.php.net to get a copy of this message
If you are having trouble setting cookies because people are coming to your site with http://domain.com instead of http://www.domain.com Try this code: // what they're requesting is without the www. if (getenv("HTTP_HOST") == "domain.com") { //then Redirect them to the properly formatted url with any //document/directory strings on the end. Header("Location: http://www.domain.com" . getenv("REQUEST_URI")); } This can be put into an include file and included at the top of every page of the site in case they surf into a sub-page. --was-- If you are having trouble setting cookies because people are coming to your site with http://domain.com instead of http://www.domain.com Try this code: <PRE> // what they're requesting is without the www. if (getenv("HTTP_HOST") == "domain.com") { //then Redirect them to the properly formatted url with any //document/directory strings on the end. Header("Location: http://www.domain.com" . getenv("REQUEST_URI")); } </PRE> This can be put into an include file and included at the top of every page of the site in case they surf into a sub-page. http://www.php.net/manual/en/function.setcookie.php

« previous php.notes (#28790) next »