Hi,
I am trying to set a language cookie.
I have a row of different flags which all have values and set a language cookie.
However i can only redirect to the homepage, and i just want to refresh the current page.
Here is my php script......
<?php
setcookie("lang", urlencode($_GET["lang"]));
$url = "http://www.bertgroup.co.uk/?q=node/16";
header( "Location: $url" );
?>
And the html i am using to link to the script.......
<a class="no_underline" href="setlang.php?lang=EN"><img class="header_language_flags" src="images/flag_EN.jpg" value="EN"/>
<a class="no_underline" href="setlang.php?lang=FR"><img class="header_language_flags" src="images/flag_FR.jpg" value="FR">
Thanks,
Rob
Setting cookie and refreshing.
Moderator: General Moderators
Re: Setting cookie and refreshing.
You could possibly use the $_SERVER['HTTP_REFERRER'] value to redirect back to the page they came from.
Code: Select all
<?php
setcookie("lang", urlencode($_GET["lang"]));
$url = $_SERVER['HTTP_REFERRER'];
header( "Location: $url" );
?>
Re: Setting cookie and refreshing.
Thanks for the reply, I have used your piece of code and it just wants to refresh to www.bertgroup.co.uk/setlang.php?lang=EN,
Any ideas how to get around this?
Thanks.
Rob
Any ideas how to get around this?
Thanks.
Rob
Re: Setting cookie and refreshing.
Why don't you just include the code at the top of every page using a common file and catch a setlang variable. Then you can just make the link open the page you are on.
Code: Select all
if(!empty($_GET['setlang']))
{
setcookie("lang", urlencode($_GET["lang"]));
}