managing web site data

25
Managing Web Site Data CS 320

Upload: cain-cardenas

Post on 02-Jan-2016

31 views

Category:

Documents


1 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Managing Web Site Data

Managing Web Site Data

CS 320

Page 2: Managing Web Site Data

Web Site Data

How do computer programs store data?Main memory: volatileDisk: permanent

By definition, Web pages are stateless and do not store data

Page 3: Managing Web Site 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?

Page 4: Managing Web Site Data

Between Web pages in the same visit: Session variables Temporary cookies

Across multiple visits to a site: Persistent cookies Databases

Approaches for Storing Web Page Data

Page 5: Managing Web Site Data

Specific Topics

Session variables Cookies Databases

Page 6: Managing Web Site Data

Session Variables

When you request a Web page, the Web server creates a session object corresponding to your browser sessionThis information is stored in the Web server's

main memory Sessions have attributes that you can

retrieve and display using program commands

Page 7: Managing Web Site Data

Session Variables

A program running on the Web server

can create session variables that store data values associated with a specific browser sessionValues are stored in Web server RAM and

associated with the session object

Page 8: Managing Web Site Data

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!

Page 9: Managing Web Site Data

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

Page 10: Managing Web Site Data

Specific Topics

Session variables Cookies Databases

Page 11: Managing Web Site Data

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

Page 12: Managing Web Site Data

Cookie Data Structure

Name/value pairs:

cookie_name=cookie_value

Example:

currUsername="morrisjp"

Page 13: Managing Web Site Data

Cookie Options

Client-sideCreated using JavaScript

Server-sideCreated using a server-side program

Page 14: Managing Web Site Data

Limitations of Cookies

Typically, browsers have limits on persistent cookies:Maximum of 20 cookies per Web siteMaximum of 300 cookies totalEach cookie can store a maximum of 4 KB of

data...

Page 15: Managing Web Site 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

Page 16: Managing Web Site Data

Specific Topics

Session variables Cookies Databases

Page 17: Managing Web Site Data

What is a database? Program for storing data

Structures data in a tabular formatMaintains 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.

Page 18: Managing Web Site Data

Web/Database Architecture

DataBase

Client workstations

Browser

Browser

Browser

Database server

Server-SidePrograms

Web server(s)

Network

Network

Programs that:• Form queries based on user inputs• Display retrieved data• Insert/update/delete user data

Commonly-used:•mySQL•Access•SQL Server•Oracle

Page 19: Managing Web Site Data

When does a Web site need a database? When the site needs to collect and store

data from site usersUsernames/passwords for site accessProduct selection and shipping informationUser inputs that need to be visible to other

users

Page 20: Managing Web Site Data

Test Yourself:For an Ecommerce Web site, what would you use to store a user's shipping information (name, address)?

a) Session variables

b) Temporary cookie

c) Persistent cookie

d) Database

e) None of the above

Page 21: Managing Web Site Data

Test Yourself:For an Ecommerce Web site, what would you use to store a user's shipping information (name, address)?

a) Session variables

b) Temporary cookie

c) Persistent cookie

d) Database

e) None of the above

Page 22: Managing Web Site Data

Test Yourself:For an Ecommerce Web site, what would you use to store a user's shopping cart contents?

a) Session variables

b) Temporary cookie

c) Persistent cookie

d) Database

e) None of the above

Page 23: Managing Web Site Data

Test Yourself:For an Ecommerce Web site, what would you use to store a user's shopping cart contents?

a) Session variables

b) Temporary cookie

c) Persistent cookie

d) Database

e) None of the above

Page 24: Managing Web Site Data

Test Yourself:For an Ecommerce Web site, what would you use to store a user's credit card information?

a. Session variables

b. Temporary cookie

c. Persistent cookie

d. Database

e. None of the above

Page 25: Managing Web Site Data

Test Yourself:For an Ecommerce Web site, what would you use to store a user's credit card information?

a. Session variables

b. Temporary cookie

c. Persistent cookie

d. Database

e. None of the above