Jump to content

Archived

This topic is now archived and is closed to further replies.

ramzess

Cookie does not allow me to come back

Recommended Posts

Sorry guys, it probably is funny.... not to me though

I have a very simple page based on html/css and some minor php

first page (lets say: www.name.com/index.php) contains simple text links (language selection).

On top of it there is such php code:

<?php
if ( $_COOKIE['LangCookie'] == eng)
header("Location: lv.php");
elseif ( $_COOKIE['LangCookie'] == ger)
header("Location: ru.php");
?>

User selects link (representing his language) and gets to www.name.com/eng/index.php
where a cookie is written:

<?php
$language = 'eng';
setcookie("LangCookie", $language, time()+60);
?>

Well I know that current time is set to 60sec's... that's for testing purposes...

[b]Here is the problem:[/b]

IF user has selected wrong language, and wants to get back to main page (language selection page),
he cant, because php code at the start of it checks the cookie content and sends him back
to page he selected first time, unless cookie has expired or is deleted from PC.

Guys, IS there a possibility to get back to main page to reselect the language?
Please, please, please...  :'(

Share this post


Link to post
Share on other sites
I would say this is more of a site design thing, but if you are looking for the php answer, here it is:

Send a variable via GET in your request back to the homepage that designates that you are going to set the language

On the homepage, check for that GET variable before redirecting anywhere.



Typically, language change items are on every page, so like I said, this can also be fixed by designing a better UI and flow for your site.

Share this post


Link to post
Share on other sites
Well at the top of your page you are checking if the cookie is set and if it is the user gets sent to the page. No way to prevent this if the cookie is set. You can set a link on those pages that would allow the user to click it which would take them to a page to delete the cookie then redirect to the lang selection page..

Share this post


Link to post
Share on other sites
[quote author=mb81 link=topic=104373.msg416290#msg416290 date=1155660224]
I would say this is more of a site design thing, but if you are looking for the php answer, here it is:

Send a variable via GET in your request back to the homepage that designates that you are going to set the language

On the homepage, check for that GET variable before redirecting anywhere.



Typically, language change items are on every page, so like I said, this can also be fixed by designing a better UI and flow for your site.
[/quote]

Thank you in advance.


Hm... Thank you very much. Though I am not so sure on how to do that.

Let's say I have a link on some of those language pages (let's say 'mainENG.php'), sending user back to main page. Ok?
So where do I define this variable I have to send via GET? On the same page? Like:

$noredirect

vhat would be the value of it?

and where would I put this GET?

And how can I check for the GET variable on the language selection page, if code:

<?phpif ( $_COOKIE['LangCookie'] == eng)
header("Location: lv.php");
elseif ( $_COOKIE['LangCookie'] == ger)
header("Location: ru.php");
?>

is on thee very top of that page above <HTML> tag?

Sorry, I must be stupid and sound just as annoying as all others who just start to get familiar with PHP. :(

Share this post


Link to post
Share on other sites
Could at least somebody please show me how you must write this expression with $_GET?

What is this variable I should send back to homepage? How?

I believe on homepage these should be something like

if isset $_GET and it's value
then something happens.. but how.. :(

Share this post


Link to post
Share on other sites
this is an example to use $_GET ok.

a link activate $_GET
[code]

<a href="what_ever.php?cmd=goit">my link</a>

[/code]


use the$_GET from the link to activate somethink.
[code]

<?php

if($_GET['cmd']=="gotit"){

do somethink

}

?>

[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.