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 6645879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:20:38+00:00 2026-05-26T00:20:38+00:00

I am setting two cookies in PHP in my root directory setcookie (st, $todays_system_date

  • 0

I am setting two cookies in PHP in my root directory

   setcookie ("st", "$todays_system_date"  );
   setcookie ("en", "$tomorrow" );

My problem is I need to set them again in a script that is in a deeper folder eg: /diary/
When I do set them and then try to read them or look at the cookies set , I find I have 2x en and 2x st cookies .

My question is how can I make reference to just one set of cookies ? and read them ?

thanks in advance

  • 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-26T00:20:38+00:00Added an answer on May 26, 2026 at 12:20 am

    Cookies are key/value pairs – they will only ever have a single value in any given scope.

    However:

    • It is possible to have more than one cookie with the same key and different values for the same domain (although it will still only have one effective value in any given scope).

    For example, if you set the cookie st in the root (/) with the value 1, and in /diary/ with value 2, the two cookies will exist in their own right. When you are in the / directory (or any subdirectory of / that is not /diary/ or a subdirectory of /diary/) the value will be 1. When you are in /diary/ or a subdirectory of /diary/ if will be 2:

    Directory         Cookie Value
    /                      1
    /somedir/              1
    /diary/                2
    /diary/subdir          2
    /somedir/diary/        1
    

    • It is possible to set the same cookie twice in the same scope, but only the later value will be effective – the later value overrides the earlier value.

    For example:

    setcookie('st',1); // st is now 1 for the current path
    setcookie('st',2); // st is now 2 for the current path
    

    If you look at the HTTP response message that is sent by PHP you will see 2 Set-Cookie: headers for the key st. However, on the next request within the cookie’s scope, only the later value 2 will be sent back to the server.

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

Sidebar

Related Questions

I'm setting up a directory application for which I need to have two separate
I am trying to coordinate cookies that were set by setcookie in PHP with
I am setting two values based on two different conditions inside for each. Is
I'm having a very specific bug in my iPhone application. I'm setting two images
I have simple issue setting a two-way databinding of a checkbox in Silverlight 3.0.
There are two options when setting up your JBPM session. You can put your
I know of two methods of setting a default parameter, but I would like
I'm setting up some VBA in excel to compare two dates to see if
I am trying to swap two LinearLayouts by setting their visibility properties to VISIBLE
I am setting up a simple test page in Python. I only have two

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.