CS453: State in Web Applications (Part 1) State in General Sessions (esp. in PHP) Prof. Tom Horton.

Slides:



Advertisements
Similar presentations
Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
Advertisements

Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Server-Side vs. Client-Side Scripting Languages
DT228/3 Web Development multi page applications/ sharing data.
Servlets and a little bit of Web Services Russell Beale.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
XP Tutorial 9 New Perspectives on JavaScript, Comprehensive1 Working with Cookies Managing Data in a Web Site Using JavaScript Cookies.
Definitions, Definitions, Definitions Lead to Understanding.
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
Session Management A290/A590, Fall /25/2014.
CSE 154 LECTURE 13: SESSIONS. Expiration / persistent cookies setcookie("name", "value", expiration); PHP $expireTime = time() + 60*60*24*7; # 1 week.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Client/Server Architectures
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Agenda Web Development Chapter 7 Review Class Discussion Issues.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Dynamic Web Sites Chris North cs3724: HCI. Presentations matt ketner, sam altman, mike gordon Vote: UI Hall of Fame/Shame?
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
CHAPTER 12 COOKIES AND SESSIONS. INTRO HTTP is a stateless technology Each page rendered by a browser is unrelated to other pages – even if they are from.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
Lecture 7 Interaction. Topics Implementing data flows An internet solution Transactions in MySQL 4-tier systems – business rule/presentation separation.
Advanced Web Forms with Databases Programming Right from the Start with Visual Basic.NET 1/e 13.
L. Grewe LAMP, WAMP and... Motivaiton Basic Web Systems with Delivery of Static and Dynamic Web Pages html, css, media javascript (“dynamic” on client.
Introduction to Internet Programming (Web Based Application)
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
Working with Cookies Managing Data in a Web Site Using JavaScript Cookies* *Check and comply with the current legislation regarding handling cookies.
CSE 154 LECTURE 12: COOKIES. Including files: include include("filename"); PHP include("header.html"); include("shared-code.php"); PHP inserts the entire.
10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0.
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Chapter 6 Server-side Programming: Java Servlets
1 Welcome to CSC 301 Web Programming Charles Frank.
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
Web Database Programming Week 7 Session Management & Authentication.
Maintaining Application State MIS3502: Application Integration and Evaluation Paul Weinberg Presentation by David Schuff.
CSCI 6962: Server-side Design and Programming Java Server Faces Scoping and Session Handling.
Copyright © 2003 Pearson Education, Inc. Slide 7-1 The Web Wizard’s Guide to PHP by David Lash.
Saving State on the WWW. The Issue  Connections on the WWW are stateless  Every time a link is followed is like the first time to the server — it has.
CP476 Internet Computing CGI1 Cookie –Cookie is a mechanism for a web server recall info of accessing of a client browser –A cookie is an object sent by.
Jan 2001C.Watters1 World Wide Web and E-Commerce Client Side Processing.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Fall 2000C.Watters1 World Wide Web and E-Commerce Clients & Client Side Processing.
WEB SERVER SOFTWARE FEATURE SETS
Web Technologies Lecture 6 State preservation. Motivation How to keep user data while navigating on a website? – Authenticate only once – Store wish list.
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
8-Mar-16 More About Servlets Session Tracking. Persistent information A server site typically needs to maintain two kinds of persistent (remembered) information:
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
COOKIES AND SESSIONS.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
WWW and HTTP King Fahd University of Petroleum & Minerals
ITM 352 Cookies.
Chapter 27 WWW and HTTP.
Web Systems Development (CSC-215)
Web Programming Language
State Handling CS 4640 Programming Languages for Web Applications
State Handling CS 4640 Programming Languages for Web Applications
Presentation transcript:

CS453: State in Web Applications (Part 1) State in General Sessions (esp. in PHP) Prof. Tom Horton

Readings Textbook: –Pages ; On the web: On-line book:

State, Stateless, HTTP We say HTTP is stateless –From one request from client/server to the next, the server: Doesn’t remember anything Can’t associate previous request with current request Advantages: simpler protocol and implementations But we need state for real apps

State and Sessions State –Variable/info we store and have repeated access to “We” is client-side app and server-side app Session –A sequence of interactions for which we remember state

One form of state: Cookies You remember cookies? Clearly an example of state –Stored on disk on client-side –Readable and writable by JavaScript –Readable and writable by server-side scripts Issues? –Security, nuisance, abuse, expiration, limitations on number, size, …

Where to Keep State? In server-side application –In Apache etc.? Why not a good idea? –In memory in the server-side program? On the server’s file-system –In files or DBMS –Now: must have user-id or session-id, and pass it around (and manage it)

Where to Keep State? (2) On the client? –On the file system: Cookies –In memory in the client Is this possible? Advantages: can’t access through JavaScript, hacking, etc. For any of these, passing things back and forth is still needed

Solutions Dynamic URLs –Input some information into the URL –Forms, CGI: GET method Cookies Hidden input fields in forms –Not displayed, but in HTML –Dynamic/changeable with JavaScript Java applets –Why does this solve the state issue?

PHP Sessions You’ve seen how PHP supports cookies PHP also support sessions directly without using cookies The key ideas: –Functions to start and end sessions –PHP and browser share a set of variables “cleanly” with little effort on your part –For a single session While the browser is open, and… Between your PHP calls to start and end session

What’s Shared $_SESSION –An associative array (super-global, like for POST or cookies) A session-id –Get it with PHP function session-id() –But you don’t really need it

Starting a Session First line in script: start_session(); Either –Creates a new session –Or “re-loads” current session Your browser knows if a session is active –So pages using sessions should always start with this

Ending a Session At some point your know you’re done. So just call: destroy_session(); Cleans up $_SESSION and session-id

Session Variables Use $_SESSION as any associative array –Re-loaded with persistent values by start_session() –As usual, not a good idea to use extract(). –POST variables can over-write these –Don’t forget isset() function

Example Live on-line example

Web sessions Textbook: pages Custom URL method –First form The script does the work –Second form: The server knows how to handle this

Where to Store Info (Revisited) What’s a “three-tier” architecture –client, server, database E.g. browser plus PHP and MySQL on server –but other possibilities Other possibilities: federated systems –Cooperating distributed systems that handle certain tasks –Examples: authentication (e.g. MS Passport), wallets, credit card processing, shippers, etc.

Some Rules of Thumb Considering storing on the client when: –It’s info where security is crucial –Where OK if info not available when a different machine is used –Where info used by more than one application or page

Custom client application We think of web browser as the client application But businesses could supply a custom SW application Advantages/Disadvantages –Can keep more user-info secure –But: user must install/update client app –Can't use it anywhere on any system

Shopping Carts Textbook, Chap 16

Shopping Cart Basics What’s the metaphor here? –Just a “trolley” in a physical store?

Shopping Cart Basics To the business, cart eventually is like a sales order or purchase order –The latter is an accepted sales order Header data –Info on buyer, shipping, payment, etc. Line-item data –Item, SKU, quantity, price, etc.

Server-Side Shopping Carts Can be more complex in the real-world than you expect. Possible that: –Catalog stored/served separately than Cart Storage –Order system separate –Orders (carts?) sent to other systems (federated systems)

Persistence Issues How many carts? By user: –Wish-list, registry, etc. vs. “real” cart In system: Textbook example: –Session cart for anonymous user; session cart for authenticated user; cart on catalog server Other saved carts –Company systems where a third-party approves orders

Possible Features, Issues Quick orders –E.g Amazon one-click Configurators –E.g. ordering a computer at dell.com Order processing –To or by third-party organization Don’t forget: integrates with Catalog, Inventory

What Processing Is Done What do you remember?

What Processing Is Done? Shop, Add items “Edit” or update cart Checkout –Get shipping info –Get payment info and approve –Confirm order Send on to Purchasing

More Processing Done See text, pages 325f. Note that these steps part of recognized industry “pipelines” built into commercial e- commerce components/servers –Steps for verfication –Price adjustments; order (sub)totals –Taxes (!) –Shipping: Multiple shipments? –Validity of order?

Look and Feel What’s good? What’s not? Features you like?