CGI II: Cookies & Stuff Web Programming.

Slides:



Advertisements
Similar presentations
Adding Dynamic Content to your Web Site
Advertisements

6/10/2015Cookies1 What are Cookies? 6/10/2015Cookies2 How did they do that?
Servlets and a little bit of Web Services Russell Beale.
IST 535 Week 1 Class Orientation / Review of Web Basics.
How the web works: HTTP and CGI explained
HTTP Cookie CSC 667/867. PERSISTENT CLIENT STATE HTTP COOKIES Cookies are a general mechanism which server side connections (such as CGI scripts) can.
Hypertext Transfer Protocol Information Systems 337 Prof. Harry Plantinga.
Session Management A290/A590, Fall /25/2014.
Topics in this presentation: The Web and how it works Difference between Web pages and web sites Web browsers and Web servers HTML purpose and structure.
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
1 ‘Dynamic’ Web Pages So far, we have developed ‘static’ web-pages, e.g., cv.html, repair.html and order.html. There is often a requirement to produce.
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
Cookies Set a cookie – setcookie() Extract data from a cookie - $_COOKIE Augment user authentication script with a cookie.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
Web application architecture
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
MySQL and PHP Internet and WWW. Computer Basics A Single Computer.
E-COMMERCE JOBS This project (Project number: HU/01/B/F/PP ) is carried out with the financial support of the Commssion of the European Communities.
Chapter 6 Server-side Programming: Java Servlets
Cookies Web Browser and Server use HTTP protocol to communicate and HTTP is a stateless protocol. But for a commercial website it is required to maintain.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
11 1 Cookies CGI/Perl Programming By Diane Zak Objectives In this chapter, you will: Learn the difference between temporary and persistent cookies.
Perl CGI What is "CGI"? Common Gateway Interface A means of running an executable program via the Web. Perl have a *very* nice interface to create CGI.
COOKIES and SESSIONS. COOKIES A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each.
Web Database Programming Week 7 Session Management & Authentication.
Perl Modules Darby Tien-Hao Chang Department of Electrical Engineering, National Cheng Kung University.
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.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP Headers Client IP Address HTTP User Login FAT URLs Cookies.
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.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
CSE 341, S. Tanimoto Lisp CGI - 1 Lisp CGI Programming for the Web Web servers can invoke Lisp to “intelligently” create web pages on the fly. We will.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
1 State and Session Management HTTP is a stateless protocol – it has no memory of prior connections and cannot distinguish one request from another. The.
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
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.
COEN 350: Network Security E-Commerce Issues. Table of Content HTTP Authentication Cookies.
The Internet What is the Internet? The Internet is a lot of computers over the whole world connected together so that they can share information. It.
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.
Sending data with CGI/Perl Please use speaker notes for additional information!
Lesson 11. CGI CGI is the interface between a Web page or browser and a Web server that is running a certain program/script. The CGI (Common Gateway Interface)
Programming for the Web Cookies & Sessions Dónal Mulligan BSc MA
PHP – Hypertext Preprocessor.
The need for persistence Consider these examples  Counting the number of “hits” on a website  i.e. how many times does a client load your web page source.
4.01 How Web Pages Work.
4.01 How Web Pages Work.
4.01 How Web Pages Work.
CGI I: Basics Web Programming.
19.10 Using Cookies A cookie is a piece of information that’s stored by a server in a text file on a client’s computer to maintain information about.
14-мавзу. Cookie, сеанс, FTP и технологиялари
Advanced Topics Web Programming.
The Request & Response object
What is Cookie? Cookie is small information stored in text file on user’s hard drive by web server. This information is later used by web browser to retrieve.
CGI II: Cookies & Stuff Web Programming.
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
4.01 How Web Pages Work.
Client-Server Model: Requesting a Web Page
Information Retrieval and Web Design
4.01 How Web Pages Work.
CGI I: Basics Web Programming.
CSCI-351 Data communication and Networks
CGI II: Cookies & Stuff Web Programming.
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
Presentation transcript:

CGI II: Cookies & Stuff Web Programming

HTTP Cookie Mechanism to store/retrieve information on the HTTP client Web server sends a “cookie” in HTTP response header cookie is stored as text file (not executable) on the client’s local drive cookie is included in subsequent HTTP request headers until expiration Syntax HTTP Response Cookie is created & sent from Web Server to Web Client (e.g., Internet Explorer) Set-Cookie: NAME=VALUE; expires=DATE; domain=DOMAIN_NAME; path=PATH e.g. Set-Cookie: user=kiyang; expires=Thursday, 09-Dec-10 11:11:22 GMT; domain= kiyang.kmu.ac.kr; path=/~kiyang/teaching HTTP Request Cookie is returned from Web Client to Web Server Cookie: NAME1=VALUE1; NAME2=VALUE2; .. e.g. Cookie: user=kiyang; Web Programming

Cookies with CGI.pm Setting Cookies Getting Cookies $cookie = cookie ( -name => “WP-cookie”, -value => “$cookieID”, -path=> “/teaching/WP/f10’, -expires=>’+24h’); print header (-cookie=>$cookie); Getting Cookies $cookie_value = cookie (‘cookie-name’);  Example: Form Form CGI CGI (sending cookie) CGI (checking cookie) Web Programming

Fetching Web Pages Using LWP::Simple #!/usr/bin/perl use LWP::Simple; $url= http://widit.knu.ac.kr/~kiyang/hello.htm; $body= get($url); print $body; Example script Web Programming

Fetching Web Pages Using WWW-Mechanize use WWW::Mechanize; $url= "http://widit.kmu.ac.kr/~kiyang/hello.htm"; # Create a mechanize object my $mech = WWW::Mechanize->new( autocheck => 1 ); # Fetch a page $mech->get($url); print $mech->content; # Fetch a page into a file $mech->get($url,":content_file"=>"hello.htm"); # Get links @links= $mech->links(); # @links: array of link object foreach $link(@links) { my($url,$text,$absurl)= ($link->url(), $link->text, $link->url_abs()); print “$url, $text, $absurl\n”; } # Find links $link= $mech->find_link(url_abs_regex=>qr|^http://ella.slis.indiana.edu|); $page= $mech->follow_link(url_abs_regex=>qr|^http://ella.slis.indiana.edu|); @pages= $mech->follow_all_links(url_abs_regex=>qr|^http://ella.slis.indiana.edu|); Mechanized Spider Example: HTML, CGI S517 Session 13, SLIS-IU

CGI Examples Email Webpage Fetch File Upload Simple Search HTML form CGI Webpage Fetch File Upload Simple Search Advanced Search S517 Session 10, SLIS-IU