Monday, May 30, 2016

Assignment 06 on Cookies, Hidden Fields, and Sessions

Cookies

Cookies are used to store text files on the local machine that will same some of the data from the webpage and then are used to keep certain information about the users selections or other data when they visit that website again.  Cookies can be set to have an expiration date to expire and then that simple text file is not valid anymore.

When creating a cookie in ASP.Net, you will need to create the cookie object that creates a cookie under any name that you choose to have. 
Then you will want that value to have a it be set to some textbox, check box, or radio button value be stored in that cookie object.
Once that value is set to what you want to place in the cookie, you will need to now create the cookie by using the Response.Cookies.Add()


Session

Session are like cookies but they expire sooner than later, as in leaving the webpage, or in a matter of minutes you will have to redo whatever you were doing on that page(like logins to banking websites).

A session cookie is usually used for a single session such as storing your shopping cart or sign in status. www.allaboutcookies.org/cookies/session-cookies-used-for.html

To create a session you will need to create the name to the variable that you want to have the textbox value to be passed into it.
Then you will need to use the keyword Session with [] (square brackets).


Hidden fields

Hidden fields is where the user stores variables locally that would not necessarily be passed up to the server but can stay local. 

These hidden fields can be done in asp.net by dragging from the toolbox, the hiddenfield box like a label or button, in the desired location of the webpage.
Hidden fields can't do much on their own with information to be passed into them or such, so an event need to be tied into them to make them work; like a page load event or button click.
There they are able to have any value passed into them and processed any way that you may want them to function as without showing the end user anything on their end of a webpage.


No comments:

Post a Comment