Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4016292
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:43:20+00:00 2026-05-20T09:43:20+00:00

I have a script where I set 2 cookies: $month = time() + 60

  • 0

I have a script where I set 2 cookies:

$month = time() + 60 * 60 * 24 * 30;
setcookie('id', $id, $month, '/');
setcookie('auth', $auth, $month, '/');
header('Content-Type: text/html; charset=utf-8');
print('<html><body>...etc....');

This does work well, but: some users have several id’s, depending on from which page (social network) they access my script through an iframe.

A user having several id’s is not a problem. But my problem is that when I ask that person to look at his cookies, he’ll report that there are several cookies called id and auth. And I can reproduce it myself too.

And I was actually expecting there always to be just 1 id and 1 auth cookie.

What can I do here?

Doesn’t calling setcookie(‘id’, …) with a new value replace the old value?

Thank you!
Alex

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:43:21+00:00Added an answer on May 20, 2026 at 9:43 am

    Cookies are based on a KV Scheme (Key=Value) concept and the Key’s act as unique identifiers.

    The three primary effectors of setcookie are

    • CREATE
      • Create a cookie with setcookie("id","value")
    • READ
      • Read a cookie with $_COOKIE["id"]
    • UPDATE
      • Update a cookie with setcookie("id","new value")
    • DELETE
      • Delete by setting the expiration in the past setcookie ("TestCookie", "", time() - 10);

    so yes your correct in your question, you should have a look at other factors that may deter the cookie states.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm hopeless at Javascript. This is what I have: <script type=text/javascript> function beginrefresh(){ //set
I have a page, test.php, with the following code: <html> <body> <form> <script type=text/javascript>
I have a site on domainA.com. It includes file.js from domainB.com: <script type=text/javascript src=http://www.domainB.com/file.js></script>
anyone have script or procedures to install SQL Server 2008 Express, set up the
I have a python script that analyzes a set of error messages and checks
I have a TSQL script that is used to set up a database as
I have a Perl script that I'm attempting to set up using Perl Threads
I am using the scripts from here http://www.quirksmode.org/js/cookies.html and have successfully created a cookie..
I have a Perl-based website that attempts to set a number of cookies on
Is it possible to preserve and get cookies which have been set by a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.