SlideShare a Scribd company logo
6
Most read
12
Most read
13
Most read
PHP File Upload, Cookies &
Session
Jamshid Hashimi
Trainer, Cresco Solution
http://www.jamshidhashimi.com
jamshid@netlinks.af
@jamshidhashimi
ajamshidhashimi
Afghanistan Workforce
Development Program
Agenda
• Date
• Include & Require
• File Upload
• Cookies
• Sessions
Date
• The PHP date() function is used to format a
time and/or date.
echo date("Y/m/d") . "<br>";
echo date("Y.m.d") . "<br>";
echo date("Y-m-d");
Date
• The strftime function can format that
timestamp in any way you’d like. You’ll pass it
a format string and the timestamp and get the
date back out.
echo strftime("%B %d, %Y", time());
Date
Include & Require
• In PHP, you can insert the content of one PHP
file into another PHP file before the server
executes it.
– require will produce a fatal error
(E_COMPILE_ERROR) and stop the script
– include will only produce a warning (E_WARNING)
and the script will continue
Include & Require
include 'filename';
or
require 'filename';
<div class="leftmenu">
<?php include 'menu.php'; ?>
</div>
DEMO 1
PHP File Upload
• With PHP, it is possible to upload files to the
server.
<!DOCTYPE html>
<html>
<body>
<form action="upload.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file"
id="file"><br>
<input type="submit" name="submit"
value="Submit">
</form>
</body>
</html>
DEMO 2
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 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.
• I am not a big fan of cookies!
Cookies
• We cannot trust data in $_COOKIES to contain
legitimate values
– Can easily modified!
setcookie(name, value, expire, path, domain);
setcookie("class", "AWD 01", time()+3600);
Session
• A PHP session variable is used to store
information about, or change settings for a
user session. Session variables hold
information about one single user, and are
available to all pages in one application.
Sessions
• php.ini – session.save_path
• Maximum size of a PHP session
– 128 M
• session_start()
• isset()
• unset()
• session_destroy()
Sessions
<?php
session_start();
// store session data
$_SESSION['visit'] = 1;
?>
<html>
<body>
<?php
//retrieve session data
echo "Pageviews=". $_SESSION['visit'];
?>
</body>
</html>
Php file upload, cookies & session
DEMO 3
QUESTIONS?

More Related Content

PPT
05 File Handling Upload Mysql
PDF
Php workshop L03 superglobals
PDF
Php workshop L04 database
PPT
File Upload
PDF
Web Development Course: PHP lecture 4
PPTX
Uploading a file with php
PPT
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PDF
Web Development Course: PHP lecture 3
05 File Handling Upload Mysql
Php workshop L03 superglobals
Php workshop L04 database
File Upload
Web Development Course: PHP lecture 4
Uploading a file with php
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
Web Development Course: PHP lecture 3

What's hot (20)

ODP
Php File Upload
PPTX
PHP Hypertext Preprocessor
PPTX
File upload php
PPTX
File Uploading in PHP
PDF
Web Development Course: PHP lecture 1
PPT
Php basic for vit university
PDF
Web Development Course: PHP lecture 2
PPT
Php File Operations
ODP
PHP BASIC PRESENTATION
PDF
New Features in PHP 5.3
PPT
PHP and MySQL
PPT
php $_GET / $_POST / $_SESSION
PPTX
Quick beginner to Lower-Advanced guide/tutorial in PHP
ODP
B03-GenomeContent-Intermine
TXT
Ip lab
PDF
Resource-Oriented Web Services
ODP
Web Scraping with PHP
PDF
When RSS Fails: Web Scraping with HTTP
PDF
Web Scraping with PHP
Php File Upload
PHP Hypertext Preprocessor
File upload php
File Uploading in PHP
Web Development Course: PHP lecture 1
Php basic for vit university
Web Development Course: PHP lecture 2
Php File Operations
PHP BASIC PRESENTATION
New Features in PHP 5.3
PHP and MySQL
php $_GET / $_POST / $_SESSION
Quick beginner to Lower-Advanced guide/tutorial in PHP
B03-GenomeContent-Intermine
Ip lab
Resource-Oriented Web Services
Web Scraping with PHP
When RSS Fails: Web Scraping with HTTP
Web Scraping with PHP
Ad

Viewers also liked (8)

PPT
Php Ppt
PDF
[Utsoa] Enews 4.11.2008
PPT
Agenda 21 eu cookie seminar - david naylor - field fisher waterhouse
PDF
Http only cookie
PDF
Cookies and sessions
PPT
2014 troop cookie manager training power point
PPTX
PHP Cookies and Sessions
PPT
Php Presentation
Php Ppt
[Utsoa] Enews 4.11.2008
Agenda 21 eu cookie seminar - david naylor - field fisher waterhouse
Http only cookie
Cookies and sessions
2014 troop cookie manager training power point
PHP Cookies and Sessions
Php Presentation
Ad

Similar to Php file upload, cookies & session (20)

PPT
Chapter 08 php advance
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
PPTX
PHP COOKIES AND SESSIONS
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
ODT
PPTX
PHP SESSIONS & COOKIE.pptx
PPT
Class 6 - PHP Web Programming
PPT
Lecture8 php page control by okello erick
PPTX
FP512 Cookies sessions
PDF
4.4 PHP Session
PPTX
PHP 2
PDF
PHP-Cookies-Sessions.pdf
PPT
Php mysql
PDF
PHP Making Web Forms
ODP
PPTX
hgoeisgiubsuigvbigbisbrgiusrbgibigbibbbb
PPTX
php part 2
PPTX
lecture 12.pptx
PDF
Web app development_cookies_sessions_14
ODT
Chapter 08 php advance
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
PHP COOKIES AND SESSIONS
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
PHP SESSIONS & COOKIE.pptx
Class 6 - PHP Web Programming
Lecture8 php page control by okello erick
FP512 Cookies sessions
4.4 PHP Session
PHP 2
PHP-Cookies-Sessions.pdf
Php mysql
PHP Making Web Forms
hgoeisgiubsuigvbigbisbrgiusrbgibigbibbbb
php part 2
lecture 12.pptx
Web app development_cookies_sessions_14

More from Jamshid Hashimi (20)

PPTX
Week 2: Getting Your Hands Dirty – Part 2
PPTX
Week 1: Getting Your Hands Dirty - Part 1
PPTX
Introduction to C# - Week 0
PPTX
RIST - Research Institute for Science and Technology
PPTX
How Coding Can Make Your Life Better
PPTX
Mobile Vision
PPTX
Tips for Writing Better Code
PPTX
Launch Your Local Blog & Social Media Integration
PPTX
Customizing Your Blog 2
PPTX
Customizing Your Blog 1
PPTX
Introduction to Blogging
PPTX
Introduction to Wordpress
PPTX
CodeIgniter Helper Functions
PPTX
CodeIgniter Class Reference
PPTX
Managing Applications in CodeIgniter
PPTX
CodeIgniter Practice
PPTX
CodeIgniter & MVC
PPTX
PHP Frameworks & Introduction to CodeIgniter
PPTX
Exception & Database
PPTX
MySQL Record Operations
Week 2: Getting Your Hands Dirty – Part 2
Week 1: Getting Your Hands Dirty - Part 1
Introduction to C# - Week 0
RIST - Research Institute for Science and Technology
How Coding Can Make Your Life Better
Mobile Vision
Tips for Writing Better Code
Launch Your Local Blog & Social Media Integration
Customizing Your Blog 2
Customizing Your Blog 1
Introduction to Blogging
Introduction to Wordpress
CodeIgniter Helper Functions
CodeIgniter Class Reference
Managing Applications in CodeIgniter
CodeIgniter Practice
CodeIgniter & MVC
PHP Frameworks & Introduction to CodeIgniter
Exception & Database
MySQL Record Operations

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Approach and Philosophy of On baking technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
KodekX | Application Modernization Development
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
Teaching material agriculture food technology
PPTX
Spectroscopy.pptx food analysis technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Machine learning based COVID-19 study performance prediction
NewMind AI Weekly Chronicles - August'25 Week I
Approach and Philosophy of On baking technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Mobile App Security Testing_ A Comprehensive Guide.pdf
Network Security Unit 5.pdf for BCA BBA.
The AUB Centre for AI in Media Proposal.docx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KodekX | Application Modernization Development
Agricultural_Statistics_at_a_Glance_2022_0.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
20250228 LYD VKU AI Blended-Learning.pptx
Teaching material agriculture food technology
Spectroscopy.pptx food analysis technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Machine learning based COVID-19 study performance prediction

Php file upload, cookies & session

  • 1. PHP File Upload, Cookies & Session Jamshid Hashimi Trainer, Cresco Solution http://www.jamshidhashimi.com jamshid@netlinks.af @jamshidhashimi ajamshidhashimi Afghanistan Workforce Development Program
  • 2. Agenda • Date • Include & Require • File Upload • Cookies • Sessions
  • 3. Date • The PHP date() function is used to format a time and/or date. echo date("Y/m/d") . "<br>"; echo date("Y.m.d") . "<br>"; echo date("Y-m-d");
  • 4. Date • The strftime function can format that timestamp in any way you’d like. You’ll pass it a format string and the timestamp and get the date back out. echo strftime("%B %d, %Y", time());
  • 6. Include & Require • In PHP, you can insert the content of one PHP file into another PHP file before the server executes it. – require will produce a fatal error (E_COMPILE_ERROR) and stop the script – include will only produce a warning (E_WARNING) and the script will continue
  • 7. Include & Require include 'filename'; or require 'filename'; <div class="leftmenu"> <?php include 'menu.php'; ?> </div>
  • 9. PHP File Upload • With PHP, it is possible to upload files to the server. <!DOCTYPE html> <html> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file"><br> <input type="submit" name="submit" value="Submit"> </form> </body> </html>
  • 11. 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 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. • I am not a big fan of cookies!
  • 12. Cookies • We cannot trust data in $_COOKIES to contain legitimate values – Can easily modified! setcookie(name, value, expire, path, domain); setcookie("class", "AWD 01", time()+3600);
  • 13. Session • A PHP session variable is used to store information about, or change settings for a user session. Session variables hold information about one single user, and are available to all pages in one application.
  • 14. Sessions • php.ini – session.save_path • Maximum size of a PHP session – 128 M • session_start() • isset() • unset() • session_destroy()
  • 15. Sessions <?php session_start(); // store session data $_SESSION['visit'] = 1; ?> <html> <body> <?php //retrieve session data echo "Pageviews=". $_SESSION['visit']; ?> </body> </html>

Editor's Notes

  • #11: PHP File Upload