Jump to content

Cookie does not allow me to come back


ramzess

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...  :'(
Link to comment
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.
Link to comment
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..
Link to comment
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. :(
Link to comment
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.. :(
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.