Presentation is loading. Please wait.

Presentation is loading. Please wait.

ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState.

Similar presentations


Presentation on theme: "ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState."— Presentation transcript:

1 ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState

2 Session Tracking Personalization Tailored to client’s needs Creates customer loyalty Requires a Session ID – represents a unique client Tradeoff: Privacy protection Release of vital, possibly private, data Tracking achieved by using Cookies ASP.NET’s HttpSessionState object Hidden input form elements and URL tracking 2

3 Cookies Text file stored by a Web site on a individual’s computer that allows the site to track the actions of the visitor Records sites that the user visits and identifies shopping preferences Cookies can store name-value pairs Web Server can never access cookies created outside the domain associated with that server Cookie’s Expires property (default is browsing session) 3

4 OptionsPage.aspx.cs Program Output 4 Server creates a cookie that stores a record of the chosen language, as well as the ISBN number for a book. When user clicks hyperlink, the cookies previously stored on the client are read and used to form a list of book recommendations

5 5 Label Web control Defines five radio buttons

6 OptionsPage.aspx 6 Request current page, does not cause a postback

7 7 Define books as a Hashtable, stores key-value Add values to Hashtable

8 8 Determines whether the user selected a language Three hyperlinks are made visible

9 9 Returns value corresponding to key contained in language New cookie object created to store language and ISBN number Cookie is added to the cookie collection sent as part of HTTP response header

10 10 Displays the recommendations created by the code-behind file Label displays text recommendations

11 11

12 12 Ensure that there is at least one cookie Add information in other cookies into list box Execute if no language was selected Method to retrieve cookies from the client

13 Recommendations Page.aspx.cs Program Output 13

14 Session Tracking with HttpSessionState HttpSessionState HttpSessionState objects can store any type of objects (not just Strings) as attribute values Example modified: The ASPX file is similar 14

15 OptionsPage.aspx.cs Program Output 15

16 Session Tracking with HttpSessionState Every Web Form includes an HttpSessionState Object, accessible through property Session of class Page Use this property Session to manipulate page’s HttpSessionState object. 16

17 Options.aspx 17

18 18

19 19

20 20 Event handler PageInit retrieves session information Indexing the Session object with key name Iterates through the Session object

21 Prog ram Outp ut 21


Download ppt "ASP.Net, Web Forms and Web Controls 1 Outline Session Tracking Cookies Session Tracking with HttpSessionState."

Similar presentations


Ads by Google