Jump to content


Photo

Cookie does not allow me to come back


  • Please log in to reply
5 replies to this topic

#1 ramzess

ramzess
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 15 August 2006 - 04:37 PM

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...

Here is the problem:

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...  :'(

#2 mb81

mb81
  • Members
  • PipPipPip
  • Advanced Member
  • 120 posts

Posted 15 August 2006 - 04:43 PM

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.

#3 DocSeuss

DocSeuss
  • Members
  • PipPipPip
  • Advanced Member
  • 73 posts
  • LocationTexas, USA

Posted 15 August 2006 - 04:44 PM

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..
"Unlimited budget? Great, for $5,000,0000 we will run your ad banner for one year"  ----Rasmus Lerdorf

#4 ramzess

ramzess
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 15 August 2006 - 08:21 PM

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.


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. :(

#5 ramzess

ramzess
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 16 August 2006 - 07:32 AM

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.. :(

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 16 August 2006 - 09:02 AM

this is an example to use $_GET ok.

a link activate $_GET

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



use the$_GET from the link to activate somethink.

<?php

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

do somethink

}

?>


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users