Sessions, Cookies, &.htaccess IT 210. Procedural Issues  Quiz #3 Today!  Homework #3 Due Friday at midnight UML for Lab 4  Withdraw Deadline is Wed,

Slides:



Advertisements
Similar presentations
LIS651 lecture 3 taming PHP Thomas Krichel
Advertisements

LIS651 lecture 3 functions & sessions Thomas Krichel
CookiesPHPMay-2007 : [‹#›] Maintaining State in PHP Part I - Cookies.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK)
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 10 Maintaining State Information Using Cookies.
APACHE SERVER By Innovationframes.com »
Web Programming Week 10 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 11/02/10.
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.
Class 8Intro to Databases Authentication and Security Note: What we discuss in class today covers moderate to low security. Before you involve yourself.
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.
CSC 2720 Building Web Applications Cookies, URL-Rewriting, Hidden Fields and Session Management.
PHP Hypertext PreProcessor. Documentation Available SAMS books O’Reilly Books.
SIMPLE ROUTER The slide made by Salim Malakouti. Next we will create the Router  What do I we mean by a router?  Routers work similar to a map. It receives.
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.
Set 13: Web Servers (configuration and security) (Chapter 21) IT452 Advanced Web and Internet Systems.
Apache and... Virtual Hosts ---- aliases mod_rewrite ---- htaccess AFNOG 11 Kigali, Rwanda May 2010 Dorcas Muthoni Courtesy: Hervey Allen.
User authentication, passwords
Web Programming Language Week 7 Dr. Ken Cosh Security, Sessions & Cookies.
Chapter 8 Cookies And Security JavaScript, Third Edition.
12/3/2012ISC329 Isabelle Bichindaritz1 PHP and MySQL Advanced Features.
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
PHP1-1 PHP Lecture 2 Xingquan (Hill) Zhu
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
1 Maryland ColdFusion User Group Session Management December 2001 Michael Schuler
Web Site Access Control with Apache Fort Collins, CO Copyright © XTR Systems, LLC Web Site Access Control Using the Apache Web Server Instructor: Joseph.
Apache Security Travis Jeffries. Introduction Authentication and Authorization Strict Access Methods Defending against Attacks Bad CGI Programs Apache.
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.
Cookies & Session Web Technology
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
1 CS 3870/CS 5870: Note 07 Lab 3 Lab 4 Test 1: Two Tables.
STATE MANAGEMENT.  Web Applications are based on stateless HTTP protocol which does not retain any information about user requests  The concept of state.
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.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
1 Apache and... Virtual Hosts ---- aliases mod_rewrite ---- htaccess AFNOG X Cairo, Egypt May 2009 Hervey Allen.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
Authentication Names and Passwords Names and Passwords Also can use Groups Also can use Groups Webmaster can “require” authentication Webmaster can “require”
Web Technology – Web Server Setup : Chris Uriarte Meeting 4: Advanced Topics, Continued: Securing the Apache Server and Apache Performance Tuning Rutgers.
How to maintain state in a stateless web Shirley Cohen
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.
COEN 350: Network Security E-Commerce Issues. Table of Content HTTP Authentication Cookies.
Cookies and Sessions in PHP. Arguments for the setcookie() Function There are several arguments you can use i.e. setcookie(‘name’, ‘value’, expiration,
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.
COOKIES AND SESSIONS.
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.
Setting and Upload Products
State Management Cookies, Sessions SoftUni Team State Management
World Wide Web policy.
Authentication & .htaccess
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.
Enhanced Web Site Design Stanford University Continuing Studies CS 22
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Client / Session Identification Cookies
How to Check if a site's connection is secure ?
Security in Web Applications
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
Configuring Internet-related services
Web Programming Language
Cookies and sessions Saturday, February 23, 2019Saturday, February 23,
CSc 337 Lecture 27: Cookies.
CSc 337 Lecture 25: Cookies.
Presentation transcript:

Sessions, Cookies, &.htaccess IT 210

Procedural Issues  Quiz #3 Today!  Homework #3 Due Friday at midnight UML for Lab 4  Withdraw Deadline is Wed, Feb 8 th  Resources and strategies when getting stuck?

Problem  HTTP is stateless  This causes problems when you want the server to “remember” a user (e.g., checkout baskets, customized presentation).  This problem is solved by using cookies and sessions

Sessions and Cookies

PHP Sessions  Remember: http is memoryless  “Sessions” provide temporary memory for web site access Created by server (e.g., PHP) Associative array (name  value pairs) Expires after ~15 minutes of inactivity Removed when browser is closed  Stored in cookies or on query string. Query string doesn’t allow for back button and has security problems UID, and program defined variables saved

Cookies are used for…  Session Management  Personalization  Web analytics

Cookies  Cookies Small text file stored in a file on client (“cookie jar”) Name/value pairs with expiration date, location, & source indicated. Can be secure (encrypted when HTTPS) or not  First party (from domain you’re visiting) vs Third Party (from different domain)  Session cookies (end when you close browser) vs persistent cookies (stored for long time and used when you revisit site)

Cookies  Set with: <?php //Calculate 60 days in the future //seconds * minutes * hours * days + current time $inTwoMonths = 60 * 60 * 24 * 60 + time(); setcookie('lastVisit', date("G:i - m/d/y"), $inTwoMonths); ?>  Retrieve with: $_COOKIE

Our goal: secure login  Secure?  Use PHP to read form, and check the results against a database If valid, set variable to ‘true’, otherwise ‘false’ Column NameTypeNullPrimary KeyExtra user_idint(8)NoPKAUTO usernamevarchar(11)No passwordvarchar(32)No

What is.htaccess  Method for remote web-server control  Support multiple users  A simple text file in a directory Called.htaccess

.htaccess  Built into Apache Other servers have other means Disabled by default  Put file into a directory to make site settings Controlled by closest file in the hierarchy

Performance Hit  If htaccess is turned on in Apache then Apache will look in every directory for an htaccess file and read it if it is there. If a file is requested out of a directory /www/htdocs/example, Apache must look for:  /.htaccess  /www/.htaccess  /www/htdocs/.htaccess  /www/htdocs/example/.htaccess  Lower file directives overrode higher ones

On the other hand …  It does allow users to control their own sub-directory tree without affecting others  There are other ways to do this but they require system-level access to Apache— which you may not want to give to users who each control their own sub-tree (website)

Use.htaccess to…  Customize error messages  Password protect sites  Block access by IP addresses  Block rippers and bots  Prevent hot linking (e.g., another site to embed images from your site)

Error messages ErrorDocument 400 /errors/badrequest.html ErrorDocument 401 /errors/authreqd.html ErrorDocument 403 /errors/forbid.html ErrorDocument 404 “Not here bucko !” ErrorDocument 500 /errors/serverx.html

Access control  Modify.htaccess: AuthUserFile /usr/local/myhome/.htpasswd AuthGroupFile /dev/null AuthName EnterPassword AuthType Basic require valid-user  Now, create a password file

.htpasswd  Put in a safe location  Username, password pairs Passwords are encrypted using a hash Eg: It210:cwQgdU78tJoCc See online site for generating passwordsonline site

Other commands  Block IPs order allow,deny deny from deny from allow from all  Block rippers RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR] RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR] RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR] RewriteCond %{HTTP_USER_AGENT} ^WebSauger RewriteRule ^.* - [F,L]

Finally  Block hot links These steal your intellectual property and your bandwidth! RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^ [NC] RewriteRule \.(gif|jpg|js|css)$ - [F]