C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




cookies in asp.net


Posted Date: 03 Jun 2008    Resource Type: Articles    Category: Web Applications

Posted By: subramanyam       Member Level: Silver
Rating:     Points: 10



HttpCookie.
1. Cookie is used for sharing data across webforms requested by same user/client and the data is stored on client/browse machine.
2. A cookie is a name value pair generated on behalf of a particular client and saved on the client machine.
3. With every request the browser automatically includes all the cookies appropriate to that request . The cookie Name-Value pairs are submitted in the form of request header called “Cookie” and they are saved on the server in the form of CGI environmental variable called as HTTPCookie.
4. Cookies generates on server(added to the response ) are rendered to the browser in a form of response header called “Set_Cookie”.
5. Every response cookie has name ,values , domain , and path , expires and secure attributes. These attributes are used by browse, while deciding whether to include the cookie in the request or not.
6. Note :- Domain , Path, Expires and Secure attributes are not included with a cookie in the request.
Type of Cookies:
1. Persistence Cookie :- Cookies which are permanently stored on the client machine in a file . This cookie values are shared by all the browser instances running on that machine.
2. NotPersistence Cookie :- This cookies which are temporarily stored in the browsers memory . These are not shared across browser instance and are also called as Session Cookie.

Notes:-
1. Every browser restricts the size of each cookie (approx to 4 kb) and also the total number of cookies (to 20 ) which is would accept from a given domain.
2. If a cookies added to the response already exists on the client and also its domain and path attributes match to the new cookie, the value of old cookie is overwritten with the value of new cookie.

HTTPSessionState.
A session is an object on server having key –value pairs created on the server on behalf of every client. This object is created on the first request from the client and the same object is reused for all subsequent requests by that client.
In session key – value pair is of type string – object and hence in session we can store any type of data alike cookies where we can only store strings. Also sessions can store any amount of data and also we can have unlimited numbers key – value pairs.
When a new session is created a unique ID is assigned to it and the same is rendered in the response as a non-persistence cookie . With all subsequent requests the browser includes this cookie and asp.net uses it for deciding about which session object to be used for that client’s request.
There is time out period defined for every session. The default is 20 minutes . If the time after the last request by the client exceeds the timeout period then these session corresponding to that client is automatically destroyed on the server.
Programmatically a session can be destroyed using Session.Abondon() . But the session i.e. variables and its data would be destroyed only in subsequent requests.
Sessionn.RemoveAll() removes all keys in the session but the session is not destroyed.
Note:- A persistence cookie will share the values across browser instances, whereas as a session does not share its values.





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Authentication and Security Mechanisms in Web Applications
Previous Resource: Sending a web Page as mail body using Gmail server
Return to Discussion Resource Index
Post New Resource
Category: Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween mask

Contact Us    Privacy Policy    Terms Of Use