Student Menu. © Lesson 3. Printable layout. Links won't function in print.

 

Notes Section

Main Text


Module 3.0

Cookies
.

The Cookies Collection is used for long-term information storage, for example, after a user has left a web site. The server may read information from or write information to a user's cookie. Cookies link a user to a page request and help to store information between sessions.

1. Creating Cookies - The Cookies method of the Response Object writes cookies.

<% Response.Cookies("Cookie") = value %>

2. Using Keys - Keys allow for one cookie to store multiple values and are used to refer to one of these multiple values.

Response.Cookies("SameCookie") ("keyONE") = valueONE 
Response.Cookies("SameCookie") ("keyTWO") = valueTWO

The HasKeys property returns a true or false value if the cookies holds multiple values.

<% Request.Cookies("Cookie").HasKeys %>

3. Persistent Cookies - Unless you make cookies persist; that is, write the cookie to the user's hard disk in the "cookie jar," the cookie's value will disappear as soon as the browser is closed or the session expires. Set an expiration date to make cookies persist.

Absolute expiration date:

<% Request.Cookies("Cookie").Expires = "April 30, 2001" %>

Relative expiration date (see the Date Function in the VBSLR):

<% Request.Cookies("Cookie").Expires = Date + 1 %>

Delete cookies by setting any date prior to "today":

<% Request.Cookies("Cookie").Expires = Date - 1 %>

Please read, outline and paraphrase Chapter Eight and review Appendix A in the course textbook. Work the Try It Out project for cookies with your own code if possible.


Module 3.1


Application Object.

Each virtual directory on the server is an application, and all its subdirectories and files are part of that application. The Application Object gives the developer control over the entire application which is defined by the virtual directory, its subdirectories and the pages contained within whether they're created statically or dynamically.

Each application has its own Application Object. Although there may be many users accessing the same application, there is only one instance of the Application Object for each application running on the web server. 

The Application Object stores variables and objects for application-scope usage. This means that any ASP page that's part of the application can access the variables and objects having application-scope.

1. The Application Object has two collections (or parts):

1.1. Contents - Contains all the variables added to the application through scripts in the global.asa.


1.2. StaticObjects - Contains all the objects added via the <OBJECT> tag in the global.asa.

2. The Application Object has four methods (or actions it can do):

2.1. Lock - Prevents users from changing variables and causing data corruption.

2.2. Unlock - Frees up locked Application Object.

2.3. Remove - Removes one item from the Contents collection.

2.4. RemoveAll - Removes all items from the Contents collection.

Please read, outline and paraphrase Chapter Eight and review Appendix A in the course textbook. Work the Try It Out project for the Application Object with your own code if possible.


Module 3.2


Global.asa File.

The global.asa file which can't be displayed to users stores all the application-scope declarations. Each application may have only one global.asa file contained within the virtual directory's root.

1. In VBScript, the global.asa has four Event Handling Subroutines:

1.1. Application_OnStart - Runs once when the application starts. Good for initialization steps like database log-on information.

1.2. Application_OnEnd - Runs when the server is stopped. Cleans up settings like any unnecessary database records.

1.3. Session_OnStart - Called at every new user session on the web site.

1.4. Session_OnEnd - Transfers temporary session variables to the database or sets application-level variables to another level when the session terminates.

Please read, outline and paraphrase Chapter Eight and review Appendix A in the course textbook. Work the Try It Out project for the global.asa file with your own code if possible.


Module 3.3


Session Object.

A page request caused by clicking on a link is an example of a detached user interaction. The powerful Session Object takes these numerous detached user interactions and converts them into a continuous series of interactions.

The Session Object has these three features: (1) Notification of beginning user session. (2) Notification of ending user session. (3) Stores user accessible information throughout the session.

1. Like the Application Object, the Session Object has two collections (or parts):

1.1. Contents - Contains all the variables established in a session without using the <OBJECT> tag.


1.2. StaticObjects - Retrieves the value for an object's specific property.

2. The Session Object has four properties (or characteristics):

2.1. SessionID - A read-only property that returns the session identification number for each user.

2.2. TimeOut - Sets the timeout period of any Session Object in minutes.

2.3. CodePage - Used for non-Roman alphabets like Chinese or Russian.

2.4. LCID - Specifies the system's location identifier that's used to display content.

3. The Session Object has one method (or action it can do):

3.1. Abandon - Destroys all objects stored in a Session Object and releases their server resources.

Please read, outline and paraphrase Chapter Eight and review Appendix A in the course textbook. Work the Try It Out project for the Session Object with your own code if possible.

 

Module 3.4

 

Exercise 3.

 
  1. Define any new vocabulary terms using the course textbook, the VBSLR and the online resources mentioned in Module 1.8.
  2. Remember that just as it took lots of time and practice to learn all the attributes and properties of HTML tags, so will be the case for the Properties, Methods, Events and Objects of ASP. Practice makes perfect!
  3. Please read, outline and paraphrase Chapter Seven and review Appendix A in the course textbook.
  4. Do all of the Try It Out exercises in Chapter Eight. You may be able to download the code from the book's publisher, Wrox, but it's better if you try writing your own based on what's shown in the course textbook.
  5. Take notes on this week’s materials including the Try It Out exercises and paraphrase them in your own words
  6. Don't forget to take the quiz, and collaborate with your online colleagues on this week's discussion board.

 

 

Module 3.5

 

Quiz 3.

Hint: All the answers are found on this page, but please still read Chapter Eight.

 

  1. What are cookies used for?
  2. What does the Application Object store?
  3. Each application has one what?
  4. Which is a property of the Session Object?
  5. Which is a method of the Session Object?