Click here to Skip to main content
15,914,071 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How to store every page textbox value into a cookies.
I have 10 asp.net webforms and more. I want store my every page textbox data in a cookies. Dont delete previous page textbox value, it will add it, I want to access as individual textbox data.

Please Help me........
Thank you...
Posted
Updated 28-May-14 20:52pm
v2
Comments
Nirav Prabtani 29-May-14 2:53am    
Why you need this??
NagaRaju Pesarlanka 29-May-14 3:00am    
Thank you for reply me,
Purpose is recent recent searches. When the user searching data using textbox and search button, I want to stored in a cookie, then I will display the textbox value in next page. That is the previous search. I want to store url also and User will come in after few days also I have to display recent searches.
Please Help me.

1 solution

Hello,

As per RFC 2109 every user agent needs to support

  • at least 300 cookies
  • at least 4096 bytes per cookie (as measured by the size of the characters that comprise the cookie non-terminal in the syntax description of the Set-Cookie header)
  • at least 20 cookies per unique host or domain name

Given this understanding, cookies may not be a good idea to store such information. HTML5 offers an alternative in form of local storage which generally has a recommended storage limit of 5MB per origin.

As far as managing cookies on server side you can use the code similar to one shown below.
C#
// Read search phrases 
if (Request.Cookies["SearchPhrases"] != null) {
    string strVal = Request.Cookies["SearchPhrases"]["textBox1"].Value;
}

// Update textbox1 value
Request.Cookies["SearchPhrases"]["textBox1"].Value = strNewValue

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900