Page 234 - DCAP408_WEB_PROGRAMMING
P. 234

Web Programming




                    Notes          But what if the user doesn’t have cookies enabled? Session variables can still be used, but there
                                   will be no way for the user to store the SessionID as he jumps from page to page. Hence, the
                                   session variables will not be saved for the user who has cookies disabled. However, session
                                   variables that are created and referenced on the same page will work fine. For example, the
                                   following script will output “Hello, World” regardless of whether or not the user has cookies
                                   enabled:
                                   <%
                                     Session(“Message”)  =  “Hello,  World!”
                                     Response.Write  Session(“Message”)
                                   %>




                                     Notes  Of course, if, on another page, the value of Session(“Message”) is referenced, only
                                     those users who have cookies enabled will have a value of “Hello, World!” there.

                                   Self Assessment

                                   Fill in the blanks:
                                   8.  The  Session  object  is  used  to  store  information  about,  or  change  settings  for  a
                                       ……………………
                                   9.  The server creates a new Session object for each new user, and destroys the ……………………
                                       when the session expires.

                                   10.  Kind of Session variables are bits of information that can be stored on a ……………………
                                       basis.

                                   9.4 ASP Application Object

                                   A group of ASP files that work together to perform some purpose is called an application. The
                                   Application object in ASP is used to tie these files together.
                                   An application on the Web may be a group of ASP files. The ASP files work together to perform
                                   some purpose. The Application object in ASP is used to tie these files together.
                                   The Application object is used to store and access variables from any page, just like the Session
                                   object. The difference is that ALL users share one Application object, while with Sessions there
                                   is one Session object for EACH user.
                                   The Application object should hold information that will be used by many pages in the application
                                   (like database connection information). This means that you can access the information from
                                   any page. It also means that you can change the information in one place and the changes will
                                   automatically be reflected on all pages.




                                     Notes  You can store values in  the Application  Collections. Information stored in  the
                                     Application collections is available throughout the application and has application scope.

                                   Store and Retrieve Application Variables

                                   Application variables can be accessed and changed by any page in the application.



          228                               LOVELY PROFESSIONAL UNIVERSITY
   229   230   231   232   233   234   235   236   237   238   239