Click here to Skip to main content
15,903,854 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi..........!

I want to know if a Cookie can save more than one Record.
I mean to say, Suppose I have a Cookie named "Users" it saves UserName and Password and
I have saved one Record, now i want to save another Record i.e another UserName and Password.


Can I save more than one Record in Same Cookie. IF yes, then, How can I read all Records from Cookie..

Thanks in Advance.....
Posted

Hi Friend,
Primarily cookies are meant to store limited string values in client side.

Cookies are usually limited to 4096 bytes and you can't store more than 20 cookies per site. By using a single cookie with subkeys, you use fewer of those 20 cookies that your site is allotted. In addition, a single cookie takes up about 50 characters for overhead (expiration information, and so on), plus the length of the value that you store in it, all of which counts toward the 4096-byte limit. If you store five subkeys instead of five separate cookies, you save the overhead of the separate cookies and can save around 200 bytes.

Better you go with cache or session to store Usernames and Passwords as list.
or else if you want to store in cookies it self you have to opt csv format.
cookieUName=Name1,Name2,Name3..
cookiePassword=Pwd1,Pwd2,Pwd3..

Like wise.

and read the cookie then split it up match the User name and password then use it.


and One question why you want to store multiple usernames and passwords in single cookie.??
 
Share this answer
 
You do need to read Basics of Cookies in ASP.NET[^]
And also read Limitations of a cookie[^]

Here, above two links will clear all your confusions and you'll easily get the answer of your question.

--Amit
 
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