Multiple URLs and cookies

From: Date: Mon, 19 Feb 2001 15:37:06 +0000
Subject: Multiple URLs and cookies
Groups: php.general 
Request: Send a blank email to php-general+get-40579@lists.php.net to get a copy of this message
Hello all! Okay, still going at it with PHP vs. JavaScript -- although one can remove the power if they disable cookies -- in fact, with the way it is set up here, it is doubtful they will get to the right page if they switch languages, but i can work that out later with a simple if-then statement that will create the link -- a test to see if cookies are enabled then print the correct URL. 1) Joe: I used the index (splash.php) and choice pages (choice.php) as per your suggestion. It works without a hitch. The cookie is set and it goes accordingly from the splash.php page once you have mad a selection. 2) Angela: I have added a third page to this mix, a lang_swap.php which is called from the document that people are looking at. So now it goes from a language button on a doc, passes a document id to the lang_swap.php page where a similar process tot he choice.php page takes place, sets the cookie value to the other language, and kicks it back to the french version of the english document (and vice-versa). It's all pretty quick, so i'm not worried about the page requests and lag. The trouble is... the lang_swap.php will not set the cookie for the language change. If i swap to french and then i go back and load the splash page, it send me to the english-front again, but it should send me to the french-front... i was having this problem before when i was trying to get this all to work... once the variable was set, i could not get it to change. Thanks for your help and in advance of some more! Jer Canadian Union of Postal Workers ------------------------------ The splash.php is as follows: ------------------------------ <?php if ((IsSet($lang)) || ($lang = "1") || ($lang = "2")) switch($lang) { case 1: header("Location: http://www.english.com/english-front-page.php"); exit; break; case 2: header("Location: http://www.franch.com/french-front-page.php"); exit; break; } ?> <HTML> ..... passes a value to choice.php... depending upon langauge select... ..... </HTML> ------------------------------ ------------------------------ The choice.php is as follows: ------------------------------ <?PHP if(strlen($lang)) { switch($lang) { case 1: setcookie ("lang", "1", "http://www.english.com/", "", 0); header("Location: http://www.english.com/english-front-page.php"); exit; break; case 2: setcookie ("lang", "2", "http://www.french.com/", "", 0); header("Location: http://www.franch.com/french-front-page.php"); exit; break; } } ?> <html> <head> <title>Choice</title> </head> <body></body> </html> ------------------------------ ------------------------------ The lang_swap.php is as follows: ----------------------------- <?PHP if ((IsSet($lang)) || ($lang = "1") || ($lang = "2")) switch($lang) { /* here is the swap */ case 1: setcookie ("lang", "2", "http://www.french.com/", "", 0); header("Location: http://www.french.com/document-fra.php?Doc_ID=$Ident"); exit; break; case 2: setcookie ("lang", "1", "http://www.english.com/", "", 0); header("Location: http://www.english.com/document-eng.php?Doc_ID=$Ident"); exit; break; } ?> <html> <head> <title>Lang Swap</title> </head> <body></body> </html>

« previous php.general (#40579) next »