ICT :Working with cookies in ASPX website

( Edit Profile )

We're on telegram, Join us now for latest updates.

Keywords: Cookie    ASPX   ICT

Cookies are a very important web resource with a common capability of storing web data for a specific length of time. It can be used to store user information either through a web browsing session or specified time which may be seconds, minutes, hours, days, months or even years.

Cookies store user information on the user's browser and make the information available to the website's request at any time. Consider the situation of 'Keep me login', 'Last seen' or you want a web user to remember what activity was last performed on the website.

The beauty of cookies is that it does not affect the browsing speed, website bandwidth, and makes browsing through a website more majestic. Cookies are like a database or memory card slot installed on every web browser so there is no doubt if a web browser would have it or not. However, some users might mistakenly or deliberately disable saving cookies from a particular web browser.

You can easily make a cookie called to save a user information, specify how long the web browser should hold the information before it disposes of the information and define a key to point to the user information. You can use the key to query the web browser on the client's side anytime the stored information is needed.

The code below would save a cookie and assign a value to it;

Response.Cookies["username"].Value = UsernameTextBox.Text;

Response.Cookies["sterm"].Expires = DateTime.Now.AddDays(1);

Create free online platform to promote your product or service click here

The above line of code would make a response call to the browser telling it to create a cookie named 'username' and assign the value of the UsernameTextBox to the created cookie. It saves the date this cookie was created and the date it would be expired. The above code set the expiration date to 24 hours meaning the web browser will automatically delete the cookie named 'username' for a website with URL http://www.asorockmedia.com.ng.

Web browser saves collection of cookies of a particular website under its url.

In the case you would want to read the content of this cookie, it is another very simple task which can be accomplished by this line of code;

string username= Request.Cookies["username"].Value ;

The above line of code reads the value of a cookie named 'username' and assigned its value to the string variable 'username'.

Turn your facebook wall to a must go site, let your friends feel happy. Share the world of funny pictures Click here

Follow us on Facebook    Follow us on Twitter

Share Post with Friends on:

Full Name

Phone Number (11 digits)

Country of Residence




Already a member ? Login : Don't worry you would be automatically redirected back here.

Facing any difficulty creating your account, send report to Admin

To advertise your products and services here. Contact us

Most Recent Comments     Previous Comments     Load More Comments

Follow us on Facebook    Follow us on Twitter

Disclaimer: Comments by the readers only express their opinion on the concerned article. Hence, Aso Rock Media shall not bear the brunt of any of such and other related opinions.

© 2018 - Aso Rock Media