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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:17:02+00:00 2026-05-20T17:17:02+00:00

I learned that when you set cookies, you give them a name, a value,

  • 0

I learned that when you set cookies, you give them a name, a value, and an expiration. This is an example I got from a book.

setcookie('test', 45, time()(60*60*24));

I understand the purpose of setting a name, so we have a way of referring to it. And I understand the purpose of setting the expiry date, but what is the purpose of setting a value? Why would we need to set a value?

  • 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-20T17:17:02+00:00Added an answer on May 20, 2026 at 5:17 pm

    The value is the very reason for which you are setting the cookie: so that the next time the browser makes a request, it repeats the value you gave it earlier back to you.

    In some occasions, even repeating just the name would be useful (in essence you are getting back one bit of information by the presence or absence of the name). Adding a value lets you keep more than one bit.

    So why keep the name if there’s going to be a value anyway? Because cookies with different names can have different expiration times, and because it can be convenient for separate components of an application or system to have a cookie dedicated to each one of them. This way, you don’t need to account for what component A did to the cookie value when you are setting (overwriting) it from component B. You have a value all to yourself, distinguished by its name.

    For completeness, I should mention that there are also other cookie attributes that can be set per-cookie (i.e. per distinct name):

    • Domain (cookie is valid only on specific domain and subdomains)
    • Path (cookie is valid only on specific request path and below)
    • Secure/HttpOnly (however, these cookies can have no value)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From browsing on this site and elsewhere, I've learned that serving websites as XHTML
I learned that by trying to use the tablesorter plug in from jquery the
From a tutorial I read on Sitepoint, I learned that I could load JS
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
I learned that compiler will expand macros while compiling. Templates are also expanded at
I've learned that static scoping is the only sane way to do things, and
So I have learned that that the Microsoft.Jet.OLEDB.4.0 data provider for querying data sources
As a developer, I've learned that I usually gain a better understanding of best/worst
I like to generate a thread dump programmatically. I've learned that there a basically
I learned today that NetBeans 6.5 should have an on-the-fly compilation of (single) Java

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.