note 9674 added to setcookie

From: Date: Sat, 18 Nov 2000 01:32:26 +0000
Subject: note 9674 added to setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-7834@lists.php.net to get a copy of this message
To choose multi language on a Site based on Cookie. Put a image flag that links to the index.php?lang=uk or index.php?lang=pt. In index.php you put <? if (($lang) and ($lang != $active_lang)) { SetCookie("active_lang", "", "", ""); SetCookie("active_lang",$lang,time()+31536000,""); header("location:index.php"); } elseif ($active_lang == '') { SetCookie("active_lang","uk",time()+31536000,""); } ?> To choose diferent file for depending for language put in index.php (Dynamic sections) <? include ("../templates/main_menu_"."$active_lang"); ?> This way you set an Active language on a Cookie. Every time that person visits your site it will be displayed in his/her pref. language. Have fun with this multi language simple script. Joao Correia joao.correia@hamala.pt http://www.php.net/manual/function.setcookie.php

« previous php.notes (#7834) next »