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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:43:51+00:00 2026-06-06T16:43:51+00:00

I have two pages, test1.aspx and test2.aspx test1.aspx has this protected void Page_Load(object sender,

  • 0

I have two pages, test1.aspx and test2.aspx

test1.aspx has this

protected void Page_Load(object sender, EventArgs e)
{
  HttpCookie cookie = new HttpCookie("test", "test");
  cookie.Expires = DateTime.Now.AddDays(1);
  Response.SetCookie(cookie);
}

test2.aspx has this

protected void Page_Load(object sender, EventArgs e)
{
  Response.Write(Response.Cookies["test"].Value);
}

The value of the cookie is null, no matter how many times I tried. I tried to open page1 and then page 2, expecting a cookie to work, but it is not working, I don’t know why.

  • 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-06-06T16:43:52+00:00Added an answer on June 6, 2026 at 4:43 pm

    I think you need to read off the Request instead of the response.

    As MSDN suggestions

    protected void Page_Load(object sender, EventArgs e) 
    {
        Response.Write(Request.Cookies["test"].Value);
    }
    

    In a web application, the request comes from the client (browser) and the response is sent from the server. When validating cookies or cookie data from the browser you should use the Request.Cookies collection. When you are constructing cookies to be sent to the browser you need to add them to the Response.Cookies collection.

    Additional thoughts on the use of SetCookie

    Interestingly for HttpResponse.SetCookie as used on your first page; MSDN says this method is not intended for use in your code.

    This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

    Even the example code found on this page uses the Response.Cookies.Add(MyCookie) approach and does not call SetCookie

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

Sidebar

Related Questions

I have two pages, NonMember.aspx and Member.aspx. If a user comes to the site,
I have two pages that inherit from one master page, First.aspx or second.aspx. Navigation
Using VB.NET in Visual Studio 2010, I have two files: test2.aspx and test2.aspx.vb. The
Here is the scenario: I have two asp pages. a.aspx is layout and b.aspx
In my page I have two divs called context and translation and in test1.php
I have two pages, A and B. I want to echo a variable written
I have two pages and I want to pass data to each other. How
I have two pages, on the first page after an event happens I change
I have two pages. First one we open with $_POST variables in its url,
Currently I have two pages: The first page contains an input form, and the

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.