SlideShare a Scribd company logo
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

What's hot (20)

PPT
Window to viewport transformation
Ankit Garg
 
PPTX
Psuedo color
Mariashoukat1206
 
PPTX
Scaling and shearing
Mani Kanth
 
PPT
Seed filling algorithm
Mani Kanth
 
DOCX
Introduction to image processing-Class Notes
Dr.YNM
 
PPTX
Design Pattern - Factory Method Pattern
Mudasir Qazi
 
PPT
Random and raster scan
ankur bhalla
 
PPT
5.3 mining sequential patterns
Krish_ver2
 
PPT
computer graphics
Megabi Mamo
 
PPT
2.4 rule based classification
Krish_ver2
 
PPTX
DDA algorithm
Yash Patel
 
PPTX
Fixed point scaling
rishi ram khanal
 
PPTX
Introduction to Image Compression
Kalyan Acharjya
 
PPTX
Color Models Computer Graphics
dhruv141293
 
PPTX
Deep learning for object detection
Wenjing Chen
 
PDF
Image Segmentation
Syed Muhammad Hammad
 
PDF
Data visualization in Python
Marc Garcia
 
PPT
Illumination model
Ankur Kumar
 
PDF
Data Visualization(s) Using Python
Aniket Maithani
 
PPTX
Computer Graphic - Lines, Circles and Ellipse
2013901097
 
Window to viewport transformation
Ankit Garg
 
Psuedo color
Mariashoukat1206
 
Scaling and shearing
Mani Kanth
 
Seed filling algorithm
Mani Kanth
 
Introduction to image processing-Class Notes
Dr.YNM
 
Design Pattern - Factory Method Pattern
Mudasir Qazi
 
Random and raster scan
ankur bhalla
 
5.3 mining sequential patterns
Krish_ver2
 
computer graphics
Megabi Mamo
 
2.4 rule based classification
Krish_ver2
 
DDA algorithm
Yash Patel
 
Fixed point scaling
rishi ram khanal
 
Introduction to Image Compression
Kalyan Acharjya
 
Color Models Computer Graphics
dhruv141293
 
Deep learning for object detection
Wenjing Chen
 
Image Segmentation
Syed Muhammad Hammad
 
Data visualization in Python
Marc Garcia
 
Illumination model
Ankur Kumar
 
Data Visualization(s) Using Python
Aniket Maithani
 
Computer Graphic - Lines, Circles and Ellipse
2013901097
 

Viewers also liked (8)

PPT
Php Ppt
Hema Prasanth
 
PDF
[Utsoa] Enews 4.11.2008
duanehutson
 
PPT
Agenda 21 eu cookie seminar - david naylor - field fisher waterhouse
agenda21
 
PDF
Http only cookie
fool2fish
 
PDF
Cookies and sessions
salissal
 
PPT
2014 troop cookie manager training power point
Teresa Stephens
 
PPTX
PHP Cookies and Sessions
Nisa Soomro
 
PPT
Php Presentation
Manish Bothra
 
Php Ppt
Hema Prasanth
 
[Utsoa] Enews 4.11.2008
duanehutson
 
Agenda 21 eu cookie seminar - david naylor - field fisher waterhouse
agenda21
 
Http only cookie
fool2fish
 
Cookies and sessions
salissal
 
2014 troop cookie manager training power point
Teresa Stephens
 
PHP Cookies and Sessions
Nisa Soomro
 
Php Presentation
Manish Bothra
 
Ad

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

PPT
Cookies & Session
university of education,Lahore
 
PPTX
PHP COOKIES AND SESSIONS
Degu8
 
PPTX
Session and cookies ,get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
PPT
PHP - Getting good with cookies
Firdaus Adib
 
PPTX
hgoeisgiubsuigvbigbisbrgiusrbgibigbibbbb
AryanSaxena86
 
PPT
Manish
Manish Jain
 
PDF
Seven steps to better security
Michael Pignataro
 
PPTX
PHP language presentation
Annujj Agrawaal
 
PPTX
PHP SESSIONS & COOKIE.pptx
ShitalGhotekar
 
PPT
Parameter Passing & Session Tracking in PHP
amichoksi
 
PPTX
4 php-advanced
Achchuthan Yogarajah
 
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
PDF
12 core technologies you should learn, love, and hate to be a 'real' technocrat
linoj
 
PPTX
Web application, cookies and sessions
hamsa nandhini
 
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
PPSX
Sessions and cookies
www.netgains.org
 
PDF
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
PPT
Lecture8 php page control by okello erick
okelloerick
 
PPTX
Session and Cookies
Kamal Acharya
 
Cookies & Session
university of education,Lahore
 
PHP COOKIES AND SESSIONS
Degu8
 
Session and cookies ,get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
PHP - Getting good with cookies
Firdaus Adib
 
hgoeisgiubsuigvbigbisbrgiusrbgibigbibbbb
AryanSaxena86
 
Manish
Manish Jain
 
Seven steps to better security
Michael Pignataro
 
PHP language presentation
Annujj Agrawaal
 
PHP SESSIONS & COOKIE.pptx
ShitalGhotekar
 
Parameter Passing & Session Tracking in PHP
amichoksi
 
4 php-advanced
Achchuthan Yogarajah
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
12 core technologies you should learn, love, and hate to be a 'real' technocrat
linoj
 
Web application, cookies and sessions
hamsa nandhini
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
Sessions and cookies
www.netgains.org
 
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
Lecture8 php page control by okello erick
okelloerick
 
Session and Cookies
Kamal Acharya
 
Ad

More from Jamshid Hashimi (20)

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

Recently uploaded (20)

PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Digital Circuits, important subject in CS
contactparinay1
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 

Php file upload, cookies & session

  • 1. PHP File Upload, Cookies & Session Jamshid Hashimi Trainer, Cresco Solution http://www.jamshidhashimi.com [email protected] @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