ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7

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

ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming cookies.
DT228/3 Web Development WWW and Client server model.
6/10/2015Cookies1 What are Cookies? 6/10/2015Cookies2 How did they do that?
How the web works: HTTP and CGI explained
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.
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.
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.
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.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
Chapter 16 The World Wide Web Chapter Goals Compare and contrast the Internet and the World Wide Web Describe general Web processing Describe several.
Server-side Scripting Powering the webs favourite services.
Comp2513 Java Servlets and Sessions Daniel L. Silver, Ph.D.
Lecture 7 Interaction. Topics Implementing data flows An internet solution Transactions in MySQL 4-tier systems – business rule/presentation separation.
JavaScript, Fourth Edition
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.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
Creating Databases for Web Applications cookie examples lab time: favorites cookies & Sessions class time for group work/questions on projects Next class:
Chapter 8 Cookies And Security JavaScript, Third Edition.
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
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.
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.
A Little Bit About Cookies Fort Collins, CO Copyright © XTR Systems, LLC A Little Bit About Cookies Instructor: Joseph DiVerdi, Ph.D., M.B.A.
1-1 HTTP request message GET /somedir/page.html HTTP/1.1 Host: User-agent: Mozilla/4.0 Connection: close Accept-language:fr request.
© 2010 Computer Science Faculty, Kabul University HTTP CONTINUED… 4 TH LECTURE 2, May, 2010 Baseer Ahmad Baheer.
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.
WEB SERVER SOFTWARE FEATURE SETS
Cookies. Cookie A cookie is a method for a Web server to maintain state information about users as users navigate different pages on the site, and as.
SESSIONS 27/2/12 Lecture 8. ? Operator Similar to the if statement but returns a value derived from one of two expressions by a colon. Syntax: (expression)
PHP and Sessions. Session – a general definition The GENERAL definition of a session in the “COMPUTER WORLD” is: The interactions (requests and responses)
 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 time the same computer requests.
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.
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.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
HTTP Transactions 1. 2 Client-Server Model 3 HTTP HyperText Transport Protocol Native protocol for WWW Sits on top of internet’s TCP/IP protocol HTTP.
COOKIES Gloria Soria Network Security COSC 356. What is a Cookie? A cookie is a piece of text that a Web Server can store on a user's hard disk. Cookies.
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
Programming for the Web Cookies & Sessions Dónal Mulligan BSc MA
File Uploads and Cookies Pat Morin COMP Outline File upload Cookies.
National College of Science & Information Technology.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Cookies Tutorial Cavisson Systems Inc..
Distributed Control and Measurement via the Internet
Tonga Institute of Higher Education IT 141: Information Systems
CSE 154 Lecture 20: Cookies.
WWW and HTTP King Fahd University of Petroleum & Minerals
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.
Client / Session Identification Cookies
Cookies and JavaScript
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.
Client / Session Identification Cookies
Chapter 27 WWW and HTTP.
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Presentation transcript:

ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7 CGI/Perl and Cookies

Cookies Definition: Information put on your computer’s hard disk by a website in the form of text files so that the website can remember the user at a later date Cookies can be used to store information such as usernames, passwords or even send current weather and news for your particular region. In other words cookies can be used to help make more customizable web pages.

Cookies Can be used for purposes such as shopping carts (E-Commerce). They can be written in a variety of languages including PERL, JavaScript, ASP, Cold Fusion and PHP. Examples of sites that use cookies are Amazon, Payless

Cookies Only the Internet site that placed the cookie on your machine can read it They are not programs Specification of cookies 1.A cookie may be no larger than 4k. 2.There may be no more than 20 cookies per domain. 3.There may be no more than 300 cookies total from all sources. Stored under the cookie directory in windows, if using MSIE Stored in the cookies.txt file, if using Netscape

Cookies 6 parameters can be passed to it 1. The name of the cookie (mandatory) 2. The value of the cookie (mandatory) 3. The expiration date of the cookie - if blank it will expire when the user closes the browser

Cookies – Parameters ctd 4. The path the cookie is valid for. 5. The domain the cookie is valid for 6. The need for a secure connection to exist to use the cookie. The pieces of information are stored as name-value pairs Each name-value pair is separated by a semi-colon

How it all works The URL of a Web site is entered into the browser, the browser sends a request to the Web site for the page. Your browser will contact Web site’s server and request its home page When the browser does this, it will look on your machine for a cookie file that the Web site has set. If it finds an the Web site’s cookie file, the browser will send all of the name-value pairs in the file to the Web site’s server along with the URL. If it finds no cookie file, it will send no cookie data.

How It Works - ctd The Web site’s Web server receives the cookie data and the request for a page. If name-value pairs are received, the Web site can use them If no name-value pairs are received, the Web site knows that you have not visited before. The server creates a new ID for you in the Web site’s database and then sends name-value pairs to your machine in the header for the Web page it sends. Your machine stores the name-value pairs on your hard disk. The Web server can change name-value pairs or add new pairs whenever you visit the site and request a page.

Example Cookie being sent from the server to the browser Content-type: text/html Set-Cookie: foo=bar; path=/; expires Mon, 09-Dec-2002 13:46:00 GMT Cookie being sent from the browser to the server Cookie: foo=bar

Perl and Cookies CGI scripts create one or more cookies and send them to the browser in the HTTP header. Browser returns the cookies to the CGI script during subsequent interactions Interface to cookies by using the cookie method()

Cookie Method Create an object of type CGI and assign it to a variable E.g. $cgiobject=new CGI; $cookie = $cgiobject->cookie(-name=>'sessionID', -value=>\%cookie_data, -expires=>'+1h', -path=>'/cgi-bin/database', -domain=>'.capricorn.org', -secure=>1);

Sending Cookies through HTTP The cookie created by cookie() method must be incorporated into the HTTP header E.g. print $cgiobject->header(-cookie=>$cookie); It is possible to send multiple cookies in the HTTP header print $cgiobject->header(-cookie=>[$cookie1,$cookie2]);

Retrieving Cookies To retrieve a cookie, request it by name by calling cookie() method with the name parameter E.g. cookie_data=$cgiobject->cookie(“sessionID");

Useful Links http://stein.cshl.org/WWW/software/CGI/cgi_docs.html#cookies http://www.cookiecentral.com http://www.katsueydesignworks.com/cgi_cookies.htm