Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

How do I prevent multiple registrants from overwriting each other's cookies?

Explorer ,
Jun 24, 2009 Jun 24, 2009

Copy link to clipboard

Copied

Here’s the problem:

1 household, multiple users who don’t log on or off. They are learning different languages. They come to the site to register and the registration part works fine. But, because they don't properly logon and off, the cookies that are set by the first registrant are overwritten by the second and so on.  When someone returns to the site, the cookies set by the second or third registrant would take the 1st registrant to the wrong login page. Is there a standard solution for this (seemingly) obvious problem?

Any ideas like:

<?php if (isset) $_COOKIE[‘targ_lang’]; {

Rename this.new $_COOKIE['targ_lang'] to $_COOKIE[‘targ_lang2’];

}

?>

I could then read the cookies on the index.php with:

<?php if (isset) $_COOKIE[‘targ_lang’] and (isset) $_COOKIE [‘targ_lang2’] {

header('Location: http://www.xxx.com/a_page_displaying_both their_languages.php');

}

?>
That page would have a

Select your language:

<a href"http://www.xxx.com/Login/<?php echo $_COOKIE['targ_lang']; ?>.php"><?php echo $_COOKIE['targ_lang']; ?></a>

or:

<a href"http://www.xxx.com/Login/<?php echo $_COOKIE['targ_lang']; ?>.php"><?php echo $_COOKIE['targ_lang']; ?></a>

They could select their language and then go to the proper login page.

Bearing in mine my inexact syntax, does that make sense and does it look like it would work?

Or, back to my original question, is there a really obvious solution to the multiple user problem I'm overlooking? (as usual)

As always,

Thanks for your help.

Brian

TOPICS
Server side applications

Views

946
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 25, 2009 Jun 25, 2009

Copy link to clipboard

Copied

Instead of storing just the target language in the cookie, store the username and the target language. When somebody logs in, check their username, and get the appropriate target language.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 25, 2009 Jun 25, 2009

Copy link to clipboard

Copied

Hi David,

Okay, that part makes sense. But how do I name them to avoid being over-written?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 25, 2009 Jun 25, 2009

Copy link to clipboard

Copied

How about using the username as the name of the cookie?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 25, 2009 Jun 25, 2009

Copy link to clipboard

Copied

Can a cookie name be set dynamically like that?

So that I could have multiple users on a computer who don't log out?

<?php setcookie("first_name", French, time(0)+3600, "/", ".cinelingua.com");

?>

So first_name would be set from the registration page input field for First

Name?

That would be really cool. What does that look like?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 26, 2009 Jun 26, 2009

Copy link to clipboard

Copied

LATEST

<?php setcookie("first_name", French, time(0)+3600, "/", ".cinelingua.com"); ?>

<?php setcookie($username, 'French', time(0)+3600, '/', '.cinelingua.com'); ?>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 25, 2009 Jun 25, 2009

Copy link to clipboard

Copied

Okay, let me limit this to one question:

How do I prevent people who share a computer, but who don't log on or off, from overwriting each others's cookies when they register on my site.
I didn't understand David's idea of using the username as the name of the cookie. What does that look like?

Brian

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines