Week 7 Server side programming PHP Scripting Language MySQL Database Apache Server IT4103 Web Programming

Slides:



Advertisements
Similar presentations
LIS651 lecture 3 functions & sessions Thomas Krichel
Advertisements

CookiesPHPMay-2007 : [‹#›] Maintaining State in PHP Part I - Cookies.
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.
SWU, Computer systems and technologies. The Objective of This Lecture To give you a very high-level overview of some of the tools for Web Programming.
Page 1 PHP, HTML, STATE Achmad Arwan, S.Kom. Page 2 PHP ( PHP: Hypertext Preprocessor) A programming language devised by Rasmus Lerdorf in 1994 for building.
Website Development Registering Users – Introducing Cookies.
Chapter 10 Managing State Information Using Sessions.
CSE 154 LECTURE 13: SESSIONS. Expiration / persistent cookies setcookie("name", "value", expiration); PHP $expireTime = time() + 60*60*24*7; # 1 week.
ASP Cookies Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Chapter 10 Maintaining State Information Using Cookies.
Objectives Learn about state information
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.
Chapter 12 Cookies and Sessions Part 2. Setting Cookie Parameters setcookie(name, value, expiration, path, host, secure, httponly) epoch – midnight on.
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 Tutorial - Anas Jaghoub Chapter 2 Control Structures.
Working with Cookies Managing Data in a Web Site Using JavaScript Cookies* *Check and comply with the current legislation regarding handling cookies.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Web Programming Language Week 7 Dr. Ken Cosh Security, Sessions & Cookies.
Creating Databases for Web Applications cookie examples lab time: favorites cookies & Sessions class time for group work/questions on projects Next class:
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
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.
PHP2. PHP Form Handling The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. Name: Age:
Cookies & Session Web Technology
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Dynamic Programming with PHP (mktime), Cookies, SQL, Authentication.
PHP Open source language for server-side scripting Works well with many databases (e.g., MySQL) Files end in.php,.php3 or.phtml Runs on all major platforms.
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.
Cookies and Sessions IDIA 618 Fall 2014 Bridget M. Blodgett.
Lecture 7 Maintaining State (cookies & sessions) & MySQL Interaction (revisited)
Sessions and Cookies State Management, Cookies, Sessions, Hidden Fields SoftUni Team Technical Trainers Software University
PHP Cookies. Cookies are small files that are stored in the visitor's browser. Cookies can be used to identify return visitors, keep a user logged into.
ECMM6018 Enterprise Networking for Electronic Commerce Tutorial 7
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)
8 th Semester, Batch 2008 Department of Computer Science SSUET.
 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.
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.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 3 PHP Advanced.
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.
Sessions and cookies (part 2) MIS 3501, Fall 2015 Brad N Greenwood, PhD Department of MIS Fox School of Business Temple University 11/19/2015.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
© Copyright 2012 Hidaya Trust (Pakistan) ● A Non-Profit Organization ● / www,histpk.org Hidaya Institute of Science & Technology
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
CHAPTER 5 SERVER SIDE SCRIPTING
Introduction to Dynamic Web Programming
PHP Cookies What is a Cookie?
CGS 3066: Web Programming and Design Spring 2016
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.
Sessions and cookies (part 2)
ITM 352 Cookies.
Web Programming Language
Cookies and Sessions in PHP
Implementing Cookies in PHP
<?php require("header.htm"); ?>
Cookies Cookie :- A cookie is often used to identify a user. A cookie is often used to identify a user. A cookie is a small file that the server embeds.
CIS 388 Internet Programming
Sessions and cookies (part 1)
Cookies and Sessions Part 2
CSE 154 Lecture 21: Sessions.
Sessions and cookies MIS 3501 Jeremy Shafer Department of MIS
Web Programming Language
CSE 154 Lecture 22: Sessions.
Web Programming Language
Advanced Concepts and AJAX
Presentation transcript:

Week 7 Server side programming PHP Scripting Language MySQL Database Apache Server IT4103 Web Programming

PHP Cookies A cookie is often used to identify a user. Cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.

Create a Cookie in PHP The setcookie() function is used to set a cookie. Note: The setcookie() function must appear BEFORE the tag. Syntax setcookie(name, value, expire, path, domain);

Example1 <?php setcookie("user", "Alex Porter", time()+3600); ?> ….. Code for execute…..

Example2 Cookie Name:

Example2 contd. <?php setcookie("name", $_POST['name'], time()+3600); if(isset($_COOKIE['name'])) { $n=$_COOKIE['name']; echo "Thank You". $n; } else { echo "may be your first visit or cookie is not set try again..."; } ?>

Delete a Cookie in PHP setcookie("name",$_POST['name'],time()-600); You should also ensure that your past setcookie the same name, same path, domain and secure parameters as originally setting the cookie

Session A session is a combination of a server-side file containing all the data you wish to store, and a client-side cookie containing a reference to the server data. The file and the client-side cookie are created using the function session_start() - it has no parameters, but informs the server that sessions are going to be used.

Starting a session session_start() Example

Exercise

Exercise

loginsession.html login form Login Form Name NIC No

loginsession.php <?php session_start(); $_SESSION['name']=$_POST['name']; $_SESSION['NIC']=$_POST['NIC']; echo " thank you "; echo " check details "; ?> check details

Session.php <?php session_start(); if(isset($_SESSION['name'])){ echo "NAME:".$_SESSION['name']." "; echo "NIC:".$_SESSION['NIC']." "; } else { echo "Session Expired"; } ?>

Example

Loginpg.php <?php if(isset($_SESSION['userid'])){ header('location:userpg.php'); } elseif(isset($_POST["login"]) && ($_POST["login"]=='login')) { session_start(); $_SESSION['userid']=$_POST["uname"]; header('location:userpg.php'); } ?> login Page User Name: Password:

Userpg.php <?php session_start(); if(!isset($_SESSION['userid'])||!$_SESSION['userid']){ header('location:loginpg.php'); } ?> Welcome ! Your Session ID is : Click here to logout

Logoutpg.php <?php session_start(); $_SESSION=array(); session_destroy(); header('location:loginpg.php'); ?>

Delete a session session_destroy(); Or $_SESSION['name'] = FALSE; Or unset($_SESSION['name']);

END.