Re: Multiple URLs and cookies

From: Date: Tue, 20 Feb 2001 20:03:11 +0000
Subject: Re: Multiple URLs and cookies
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-40811@lists.php.net to get a copy of this message
I don't know how it will work, or even if you can do whatever it is you are trying to do. I only know what won't work. header("Location:")+setcookie() in one script will not work on many browsers. At a guess, I'd say you'll have to include() the file the user was attempting to reach while switching languages rather than doing the redirect. Or, perhaps the content negotiationn will be sufficient. http://apache.org Or, maybe you'll need to have a language-switching page after all. -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: Jeremy Gillies <jgillies@cupw-sttp.org> To: 'Richard Lynch' <richard@zend.com>; <php-general@lists.php.net> Sent: Tuesday, February 20, 2001 8:31 AM Subject: RE: [PHP] Multiple URLs and cookies > How will that work with three URLs and frequent language switching? > > Thanks, > jer > > > You can't do setcookie and Location: in the same page. > > Once they picked a language, set the cookie and return the > > HTML content for > > that home page, don't redirect. > > > > -- > > Visit the Zend Store at http://www.zend.com/store/ > > Wanna help me out? Like Music? Buy a CD: > > http://l-i-e.com/artists.htm > > Volunteer a little time: > > http://chatmusic.com/volunteer.htm > > ----- Original Message ----- > > From: Jeremy Gillies <jgillies@cupw-sttp.org> > > Newsgroups: php.general > > Sent: Monday, February 19, 2001 9:43 AM > > Subject: [PHP] Multiple URLs and cookies > > > > > > > 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> > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > >

« previous php.general (#40811) next »