CGI II: Cookies & Stuff Web Programming.

Slides:



Advertisements
Similar presentations
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
Advertisements

Adding Dynamic Content to your Web Site
6/10/2015Cookies1 What are Cookies? 6/10/2015Cookies2 How did they do that?
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.
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.
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.
Cookies COEN 351 E-commerce Security. Client / Session Identification HTTP does not maintain state. State Information can be passed using: HTTP Headers.
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
Working with Cookies Managing Data in a Web Site Using JavaScript Cookies* *Check and comply with the current legislation regarding handling cookies.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
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.
Website Development with PHP and MySQL Saving Data.
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.
Web Database Programming Week 7 Session Management & Authentication.
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.
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
Web Server.
 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.
Web Authoring with Dreamweaver. Unit Objectives  Be able to define keywords: HTML, HTTP (protocol), browser, web server, client/server, tag, attribute,
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.
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
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.
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.
Chapter 7 - Introduction to Common Gateway Interface (CGI)
4.01 How Web Pages Work.
Y.-H. Chen International College Ming-Chuan University Fall, 2004
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.
1 CHAPTER 10 ADVANCED PHP.
Some Common Terms The Internet is a network of computers spanning the globe. It is also called the World Wide Web. World Wide Web It is a collection of.
14-мавзу. Cookie, сеанс, FTP и технологиялари
Part 2 Setting up a web server the easy way
Advanced Topics Web Programming.
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.
<?php require("header.htm"); ?>
CGI II: Cookies & Stuff Web Programming.
Chapter 2 Interacting with the Customer
Part 2 Setting up a web server the easy way
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
4.01 How Web Pages Work.
Information Retrieval and Web Design
PHP-II.
4.01 How Web Pages Work.
CGI I: Basics Web Programming.
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

Reference/Pointer A reference Syntax a pointer to something (e.g. array, hash) a variable that refer to other variables contain a memory address of data good for working with large data structures creating complex data structures Syntax to create a reference $ptr1= \$scalar; $ptr2= \@array; $ptr3= \%hash; $ptr4= [1, 2, 3]; $ptr5= { k1=>v1, k2=>v2} to get the value Variable (i.e. scalar, array, hash) $$ptr1; @$ptr2; %$ptr3; Element of array/hash $$ptr2[0]; $$ptr3{0}; $ptr2->[0]; $ptr3->{0}; S517 Session 12, IU-SLIS

Multi-dimensional Arrays Using anonymous arrays $array = [ [id1,pw1], [id2,pw2], [id3,pw3] ]; for ($i=0; $i<=2; $i++) { for ($j=0; $j<=1; $j++) { print “$array -> [i][j]\n”; } Using array references @a1= (id1,pw1); @a2= (id2,pw2); @a3= (id3,pw3); @array = (\@a1, \@a2, \@a3); # array of array pointers for ($i=0; $i<=2; $i++) { $ptr= $array[$i]; print “@$ptr\n”; Examples: #1, #2, #3, #4, #5 S517 Session 12, IU-SLIS