0% found this document useful (0 votes)
33 views2 pages

Cookies: - : We Can Create Sub Key For Cookies Drawback

The document discusses key properties of cookies including that they store data in text files on the client machine, can only store string values, have a default size limit of 50 bytes and maximum of 4096 bytes, and are URL specific by default. It also outlines some drawbacks of cookies such as size limitations, the ability of users to manipulate or disable cookies. The document then provides an example of how to create cookies through code behind in C# by adding a cookie to the response with expiration date and values from text boxes if a checkbox is checked.

Uploaded by

CHIRAG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

Cookies: - : We Can Create Sub Key For Cookies Drawback

The document discusses key properties of cookies including that they store data in text files on the client machine, can only store string values, have a default size limit of 50 bytes and maximum of 4096 bytes, and are URL specific by default. It also outlines some drawbacks of cookies such as size limitations, the ability of users to manipulate or disable cookies. The document then provides an example of how to create cookies through code behind in C# by adding a cookie to the response with expiration date and values from text boxes if a checkbox is checked.

Uploaded by

CHIRAG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Cookies: -

Key Terms or properties regarding cookies: -

1) To store data in text files and that text file reside on the client machine.
2) We can store only string values not object.
3) Scope: - Multiple pages.
4) By default cookies are temporary and temporary cookie stored in browser
only.
5) But we can create permanent cookies, we can specify expiry date and time
according to the user.
6) By default cookies are URL specific means gmail is not supported in yahoo)
7) Per site 20 cookies can be created in one website
8) Initial size of cookie is 50 bytes.
9) Maximum size of cookie is 4096 bytes.

We can create sub key for cookies

Drawback: -
1) Size limitation
2) User can manipulate the cookies.
3) User can enable or disable the cookies.

How to create the cookies through the code behind technique.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie ck = Request.Cookies["myckk"];
}
protected void Button1_Click(object sender, EventArgs e)
{
if(TextBox1.Text == "abc" && TextBox2.Text == "xyz")
{
Response.Redirect("default3.aspx");
}
else
{
Response.Write("wrong uname/pwd");
}
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked == true)
{
HttpCookie ck = new HttpCookie("myckk");
ck.Values.Add("un", TextBox1.Text);
ck.Values.Add("up", TextBox2.Text);
ck.Expires = DateTime.Now.AddDays(1);
Response.Cookies.Add(ck);
}
}
}

Output will be given after creating the cookies through the programming: -

You might also like