Web Application Data

Download Report

Transcript Web Application Data

Managing Web
Site Data
CS 320
Web Site Data

How do computer programs store data?
 Main
memory: volatile
 Disk: permanent

By definition, Web pages are stateless
and do not store data
Browser Session


Begins when the user opens the browser and
connects to a site
Ends when the user navigates to a new page or
closes the browser
 All


input data is lost...
What kind of data might you want to store across
pages during a single visit to a Web site?
What kind of data might you want to store across
multiple visits to the same Web site?
Approaches for Storing Web
Page Data

Between Web pages in the same visit:
 Session
variables
 Temporary cookies

Across multiple visits to a site:
 Persistent
cookies
 Databases
Specific Topics
Session variables
 Cookies
 Databases

Session Variables

When you request a Web page, the Web
server creates a session object
corresponding to your browser session
 This
information is stored in the Web server's
main memory

Sessions have attributes that you can
retrieve and display using program
commands
Session Variables
A program running on the Web server
can create session variables that store
data values associated with a specific
browser session

 Values
are stored in Web server RAM and
associated with the session object
Session Timeout Intervals

By default, server/browser sessions "time out"
(close) after a specific period of inactivity:
 Microsoft
IIS: 20 minutes
 Tomcat: 30 minutes
 You can change these values to longer/shorter ones

At that point, the session closes and the session
object is destroyed
 All
session variable data is lost!
Limitations of Session Variables

Usually have a limited size
 Often
limited to a maximum size of 300
characters

Values are lost when the session ends or
times out
Specific Topics
Session variables
 Cookies
 Databases

What is a Cookie?



Data item stored on the client workstation
Can (theoretically) be read/modified only by Web
pages associated with the same Web server
domain that originally created it
Cookie types:
 Temporary
(session): only lasts during the current
session


Stored in client (browser) RAM
Can be read only in current browser session
 Persistent:
stores data in the client file system that is
available across multiple browser sessions
Cookie Data Structure
Name/value pairs:
cookie_name=cookie_value

Example:
currUsername="morrisjp"

Cookie Options

Client-side
 Created

using JavaScript
Server-side
 Created
using a server-side program
Limitations of Cookies

Typically, browsers have limits on
persistent cookies:
 Maximum
of 20 cookies per Web site
 Maximum of 300 cookies total
 Each cookie can store a maximum of 4 KB of
data...
More Limitations of Cookies

Stored locally
 If
you use multiple computers, you will have different
sets of cookies

Possibility of:
 Information
theft
 Cookie poisoning

Other Web sites change cookie contents
 Profiling


Marketers create cookies that are shared among sites
Users can disable cookies in their browser
Specific Topics
Session variables
 Cookies
 Databases

What is a database?

Program for storing data
 Structures
data in a tabular format
 Maintains relationships among data items

Example: customers make reservations
 Has
built-in programs to perform the basic
data handling tasks

Insert, update, delete, retrieve
 Has
built-in features for managing multiple
users, security, backups, etc.
Web/Database Architecture
Data
Base
Commonly-used:
•mySQL
•Access
•SQL Server
•Oracle
Client workstations
Web server(s)
Database server
N
e
t
w
o
r
k
Server-Side
Programs
N
e
t
w
o
r
k
Browser
Browser
Browser
Programs that:
• Form queries based on user inputs
• Display retrieved data
• Insert/update/delete user data
When does a Web site need a
database?

When the site needs to collect and store
data from site users
 Usernames/passwords
for site access
 Product selection and shipping information
 User inputs that need to be visible to other
users
Test Yourself:
For an Ecommerce Web site, what would
you use to store a user's shipping
information (name, address)?
a)
b)
c)
d)
e)
Session variables
Temporary cookie
Persistent cookie
Database
None of the above
Test Yourself:
For an Ecommerce Web site, what would
you use to store a user's shipping
information (name, address)?
a)
b)
c)
d)
e)
Session variables
Temporary cookie
Persistent cookie
Database
None of the above
Test Yourself:
For an Ecommerce Web site, what would
you use to store a user's shopping cart
contents?
a)
b)
c)
d)
e)
Session variables
Temporary cookie
Persistent cookie
Database
None of the above
Test Yourself:
For an Ecommerce Web site, what would
you use to store a user's shopping cart
contents?
a)
b)
c)
d)
e)
Session variables
Temporary cookie
Persistent cookie
Database
None of the above
Test Yourself:
For an Ecommerce Web site, what would
you use to store a user's credit card
information?
a.
b.
c.
d.
e.
Session variables
Temporary cookie
Persistent cookie
Database
None of the above
Test Yourself:
For an Ecommerce Web site, what would
you use to store a user's credit card
information?
a.
b.
c.
d.
e.
Session variables
Temporary cookie
Persistent cookie
Database
None of the above