Verdon Vaillancourt wrote: > I am trying to build a simple mechanism to allow visitors to set a site > preference (stored in a cookie) by clicking on a link. I want the > cookie set and the original page reloaded with the new cookie set, when > a visitor clicks on the link. > > My link looks like this... > > <a href="/switch.php?userLangChoice=fr&sender=<?php echo > $_SERVER['REQUEST_URI']; ?>">French</a> > > My file switch.php looks like this... > > <?php > > setcookie("userLang", $userLangChoice); > > if ($sender == "") > $sender = "index.php"; > else > $sender = "$sender"; > > header("location:".$sender); > > ?> > > Now, for the most part this works fine, but in some cases, my referring > URL ($sender) is being truncated. Simple URLs such as > '/listingsearch.php?Category%5B%5D=Hunting' work fine, although it is > being returned as '/listingsearch.php?Category[]=Hunting'. More complex > URLs like > '/listingsearch.php? > Accommodation%5B%5D=Outpost&Category%5B%5D=Fishing&Region%5B%5D=North- > West' are being truncated at the first variable down to > '/listingsearch.php?Accommodation[]=Outpost' > > Is there something I can do to make sure the referring URL is not > truncated and it would also be nice if it was left alone and not > encoded or decoded. Your very problem is that you are NOT encoding the URL data, so the browser is trying to do it for you, only it can't be sure whether & is supposed to be data or is supposed to separate your URL arguments. http://php.net/urlencode You may also want to just include the switch.php whenever userLangChoice is set in the URL: ----------- langchoic.inc ------------- <?php if (isset($_GET['userLangChoice'])){ setCookie($_GET['userLangChoice']); } ?> You can simply: <?php include 'langchoice.inc'?> on every page or in a globals file you already include, and then you're not wasting a bunch of HTTP connections bouncing around with the header or worrying about your URL getting munged. <?php include 'langchoice.inc'; echo "<a href=\"$_SERVER[PHP_SELF]?userLangChoice=fr\">French</a>"; echo "<a href=\"$_SERVER[PHP_SELF]?userLangChoice=en\">English</a>"; ?> -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php