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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:05:33+00:00 2026-06-05T09:05:33+00:00

Here is the page where I am retrieving from a XML page and by

  • 0

Here is the page where I am retrieving from a XML page and by storing it in cookie, I want to retrieve it in another page.

public partial class shopping : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        HttpCookie userCookie = new HttpCookie("user");
        userCookie["quantity"] = TextBox1.Text;

        XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("shopping_cart.xml"));
        XmlNode root = doc.DocumentElement;

        if (RadioButton1.Checked)
        {
            string str1 = doc.GetElementsByTagName("cost").Item(0).InnerText;
            userCookie["cost"] = str1;
            //Label3.Text = str1;
            Response.Redirect("total.aspx");
        }

    }
}

and here is other page where I am trying to retrieve it (total.aspx.cs):

public partial class total : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        **Label2.Text = Request.Cookies["user"]["quantity"];**

    }
}

I am getting a Null Reference on the line which is in bold. Any suggestions on how can I do it?

  • 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-05T09:05:35+00:00Added an answer on June 5, 2026 at 9:05 am

    You created the cookie in the first section, but forgot to append it to the Response.

     Response.Cookies.Add(userCookie); // place before your Response.Redirect
    

    Also, be aware that cookies have a useful maximum size of 4000 bytes, and otherwise a probably not the best choice for what you are doing. You may wish to store temporary session info in the Session for access between pages, rather than use a cookie.

     Session["quantity"] = TextBox1.Text
    
     // ...
    
     Session["cost"] = str1;
    

    and in the second page

    Label2.Text = Session["quantity"] as string;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to load json information from another page in my site with ajax.
here is the situation. I'm retrieving a page using curl into a variable. So
here is the page i want to parse (the api link i gave is
How do I post them to whatever page from here and how can I
I am trying to retrieving image from sql server 2005 into asp.net web page
The php.net page here http://www.php.net/manual/en/mysqlinfo.library.choosing.php says this Configure commands for using mysqlnd // Recommended,
So I have this page here: http://www.eminentmedia.com/development/powercity/ As you can see when you mouse
If you look on this page here in Firefox (I'm on 3.5.2 on a
Hi i am trying to redirecting visualforce page to google.com page here is my
Here is a page I am trying to make print friendly, so it will

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.