Cookies - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Cookies

Description:

In Microsoft ASP/VBScript, there are methods and instance variables in the ... Cookies in ASP/VBScript. Setting a cookie: ... an ASP/VBScript internal variable. ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 20
Provided by: valueds288
Category:
Tags: cookies | vbscript

less

Transcript and Presenter's Notes

Title: Cookies


1
Cookies
  • Cookies are bits of software placed on the client
    machine when browsing web site.
  • Its a text file !
  • Cookies are a used for
  • Customizing user experience
  • Maintain use information

2
Cookies in ASP/VBScript
  • In Microsoft ASP/VBScript, there are methods and
    instance variables in the request and response
    objects dedicated to the handling of cookies.
  • Before using these, it is important to note that
    the ASP/VBScript associate a name with a cookie.

3
Cookies in ASP/VBScript
  • Setting a cookieIt is necessary to invoke the
    cookies instance variable of the response object
    with 1. String valued parameter
    (name) 2. Assign suitable value to the variable.
  • Response.cookies(visits) 1

4
Cookies Collection
5
Cookies Collection
6
Example 1 Code
  • lt CheckCookie request.cookies("Example")
  • If CheckCookie "" Then
  • response.cookies("Example").expires date 7
  • response.cookies("Example") "eyhab almasri"
  • response.write("Cookie created")
  • Else
  • name request.cookies("Example")
  • response.write(name)
  • End If
  • gt

7
Cookie Expiration
  • The expires simply specifies when the browser may
    discard the cookie from its permanent location.
  • It is usually used to set the time period for
    which a persistent cookie is stored.
  • It is set to an absolute date.
  • If the date specified is earlier than today, the
    cookie is immediately discarded.
    response.cookies("route").expires date 1
  • Date is an ASP/VBScript internal variable.

8
Examples Demo 1
  • lt CheckCookieA request.cookies("Example1")
  • CheckCookieB request.cookies("Example2")
  • If CheckCookieA "" Then
  • response.cookies("Example1").expires Now() 1
  • response.cookies("Example1")("Name") "Eyhab
    Al-Masri"
  • response.write("Created Cookie A" "ltbrgt")
  • Else
  • response.write("Cookie A returned" "ltbrgt")
  • response.write("Hello " request.cookies("Exampl
    e1")("Name") " ! Welcome backltbrgt")
  • End If
  • gt
  • ltbrgtltbrgt
  • lt
  • If CheckCookieB "" Then
  • response.cookies("Example2").expires Now() 1
  • response.cookies("Example2")("Major")
    "Computer Science"
  • response.write("Created Cookie B" "ltbrgt")
  • Else
  • response.write("Cookie B returned" "ltbrgt")

9
Examples Demo 2
  • lt CheckCookieA request.cookies("Example1")
  • CheckCookieB request.cookies("Example2")
  • If CheckCookieA "" Then
  • response.cookies("Example1").expires Now() 1
  • response.cookies("Example1")("Name") "Eyhab
    Al-Masri"
  • response.write("Created Cookie A" "ltbrgt")
  • Else
  • response.cookies("Example1") ""
  • End If
  • gt
  • ltbrgtltbrgt
  • lt
  • If CheckCookieB "" Then
  • response.cookies("Example2").expires Now() 1
  • response.cookies("Example2")("Major")
    "Computer Science"
  • response.write("Created Cookie B" "ltbrgt")
  • Else
  • response.write("Cookie B returned" "ltbrgt")
  • response.write("Major is " request.cookies("Exa
    mple2")("Major") "ltbrgt")

10
Sessions
  • How do you keep user-specific information while a
    user navigates through the site?
  • Session object represents the current users
    session on the web server
  • User specific
  • Properties and methods allow for information
    manipulation

11
Sessions
  • Web servers identifies each user session with a
    unique session ID
  • Demo 1
  • You can create other session variables and
    customize the session based on your needs.
  • Sessions are important in maintaining information
    about users.

12
Sessions
  • Properties
  • CodePage (character set)
  • LCID (formatting dates)
  • SessionID (unique identifier)
  • Timeout (length in minutes for keeping session
    alive, def 20 mins)
  • Collections
  • Contents
  • StaticObjects
  • Methods
  • Abandon (releases memory used by web server for
    sessions)
  • Events
  • Session_OnEnd
  • Session_OnStart

13
Why use Databases
  • Small, medium an large-sized business use
    databases to track inventory, employees, etc.
  • Explosion of the internet.
  • Increase profitsmanaging-creating-and delivery
    information over the web.

14
Databases
  • A Database is a collection of facts that are
    systematically organized (Ashenfelter 1999) it
    is an information container.
  • Most common type of databases is the relational
    databases.
  • It usually consists of the following objects
    Tables, Queries, Forms, and Reports.

15
Databases
  • TablesData is stored in tables, as records of
    information related to a single subject. Records
    store pieces of information as fields, and Each
    field may have a specific data type associated
    with it.

16
Databases
  • Queriesare general-purpose utility tools such
    as deleting/updating specific records.
  • Forms-The user interface of database
    applications -Generally accessed directly
    (adding, editing, deleting, or searching for
    individual records)
  • Reportsprinting specific records or group of
    records for specific purposes

17
Relational Databases
  • By using a common identifier between tables it is
    possible to "relate" one table to another.
  • ScenarioFor instance, imagine you had a table
    that contained data about items sold in a store
    today.
  • You also have tables that give you the details
    about the items and the vendors that sell them to
    you.

18
Primary Key
  • Valid Tablesmust have one field with values
    that are NOT the same for two different
    records.This is what is called Primary Key for
    that table.
  • These fields are used to link or relate tables
    to each other.

19
Relationships
  • Microsoft Access is a relational databaseall
    data can be stored in one database file where the
    file can contain multiple tables with defined
    relationships between the tables.
  • In previous example, we used to store teacher
    information
Write a Comment
User Comments (0)
About PowerShow.com