SlideShare a Scribd company logo
PHP
(Cookies, cURL, Session,)
Setting a Cookie
setcookie("user", "Tom", time() + 86400, "/"); // check syntax for function params
• Creates a cookie with name user
• (Optional) Value of the cookie is Tom
• (Optional) Cookie will expire in 1 day (86400 seconds) (Optional) Cookie is available
throughout the whole website /
• (Optional) Cookie is only sent over HTTPS
• (Optional) Cookie is not accessible to scripting languages such as JavaScript
Checking if a Cookie is Set
if (isset($_COOKIE['user'])) { // true, cookie is set
echo 'User is ' . $_COOKIE['user'];
}else { // false, cookie is not set
echo 'User is not logged in';
}
Removing a Cookie
setcookie('user', '', time() - 3600, '/');
Or
unset($_COOKIE['user']);
Retrieving a Cookie
echo $_COOKIE['user'];
cURL
is a tool for transferring data with URL syntax. It support HTTP,
FTP, etc
a little script check is the cURL extension loaded or not
if(!extension_loaded("curl")) {
die("cURL extension not loaded! Quit Now.");
}
// Actual script start //
create a new cURL resource //
$curl is the handle of the resource
$curl = curl_init();
// set the URL and other options
curl_setopt($curl, CURLOPT_URL,"http://www.example.com");
// execute and pass the result to browser
curl_exec($curl); // close the cURL resource
curl_close($curl);
Session
data accessible across the various pages of an entire
website is to use a PHP Session
• Start session
session_start();
$_SESSION[user'] = ‘gptUser123’;
• Destroying Session
unset($_SESSION['counter']);
session_destroy();
?
1. what id diff b/w session and cookie
2. where you use cookie
3. what is the use of session in your web page
4. have you know any cURL equal method

More Related Content

What's hot (20)

PDF
Chrome拡張開発者のためのFirefox拡張開発
swdyh
 
TXT
新建 文本文档
mytwice
 
PPT
PHP - Introduction to PHP Cookies and Sessions
Vibrant Technologies & Computers
 
ODP
Day 2-some fun coding
Open Knowledge Nepal
 
PDF
mdpress(MarkDown Press)を使ったプレゼンテーション作成
達郎 植田
 
PDF
Couchdb w Ruby'm
Stanisław Wasiutyński
 
PPT
New kid on the block node.js
Joel Divekar
 
PDF
Message Decrypt
Neil VonHoltum
 
PPTX
Cookies in php
ArunaDevi63
 
TXT
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Arian Gutierrez
 
PDF
Mac OS X Lion で作る WordPress local 環境
Yuriko IKEDA
 
PPTX
Php cookies
JIGAR MAKHIJA
 
PDF
San Francisco Java User Group
kchodorow
 
PDF
Mastering the MongoDB Shell
MongoDB
 
PDF
Synchronisation de périphériques avec Javascript et PouchDB
Frank Rousseau
 
TXT
Mounting usb free bsd
Kang Izur
 
PPTX
Ch4(saving state with cookies and query strings)
Chhom Karath
 
PDF
File-I/O -- ist doch ganz einfach, oder?
Christian Kauhaus
 
PPTX
Javascript ch3
Brady Cheng
 
Chrome拡張開発者のためのFirefox拡張開発
swdyh
 
新建 文本文档
mytwice
 
PHP - Introduction to PHP Cookies and Sessions
Vibrant Technologies & Computers
 
Day 2-some fun coding
Open Knowledge Nepal
 
mdpress(MarkDown Press)を使ったプレゼンテーション作成
達郎 植田
 
Couchdb w Ruby'm
Stanisław Wasiutyński
 
New kid on the block node.js
Joel Divekar
 
Message Decrypt
Neil VonHoltum
 
Cookies in php
ArunaDevi63
 
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Arian Gutierrez
 
Mac OS X Lion で作る WordPress local 環境
Yuriko IKEDA
 
Php cookies
JIGAR MAKHIJA
 
San Francisco Java User Group
kchodorow
 
Mastering the MongoDB Shell
MongoDB
 
Synchronisation de périphériques avec Javascript et PouchDB
Frank Rousseau
 
Mounting usb free bsd
Kang Izur
 
Ch4(saving state with cookies and query strings)
Chhom Karath
 
File-I/O -- ist doch ganz einfach, oder?
Christian Kauhaus
 
Javascript ch3
Brady Cheng
 

Similar to Php Basics part 1 (20)

PDF
4.4 PHP Session
Jalpesh Vasa
 
PPTX
FP512 Cookies sessions
Fatin Fatihayah
 
PDF
Web app development_cookies_sessions_14
Hassen Poreya
 
PPTX
PHP COOKIES AND SESSIONS
Degu8
 
PDF
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
PPT
Lecture8 php page control by okello erick
okelloerick
 
PDF
Introduction to php web programming - sessions and cookies
baabtra.com - No. 1 supplier of quality freshers
 
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
PPT
PHP-07-Cookies-Sessions indepth powerpoint
spadhi2
 
PPTX
PHP SESSIONS & COOKIE.pptx
ShitalGhotekar
 
PPT
Cookies & Session
university of education,Lahore
 
PPT
Php 07-cookies-sessions
YUSRA FERNANDO
 
PPT
16 cookies
Abhijit Gaikwad
 
PPT
Session,cookies
rkmourya511
 
PPSX
Sessions and cookies
www.netgains.org
 
PDF
PHP Making Web Forms
krishnapriya Tadepalli
 
PPT
Php Sessoins N Cookies
mussawir20
 
PPTX
murach12.pptx
xiso
 
4.4 PHP Session
Jalpesh Vasa
 
FP512 Cookies sessions
Fatin Fatihayah
 
Web app development_cookies_sessions_14
Hassen Poreya
 
PHP COOKIES AND SESSIONS
Degu8
 
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
Lecture8 php page control by okello erick
okelloerick
 
Introduction to php web programming - sessions and cookies
baabtra.com - No. 1 supplier of quality freshers
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
PHP-07-Cookies-Sessions indepth powerpoint
spadhi2
 
PHP SESSIONS & COOKIE.pptx
ShitalGhotekar
 
Php 07-cookies-sessions
YUSRA FERNANDO
 
16 cookies
Abhijit Gaikwad
 
Session,cookies
rkmourya511
 
Sessions and cookies
www.netgains.org
 
PHP Making Web Forms
krishnapriya Tadepalli
 
Php Sessoins N Cookies
mussawir20
 
murach12.pptx
xiso
 
Ad

Recently uploaded (20)

PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PPTX
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PPTX
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Day2 B2 Best.pptx
helenjenefa1
 
GitOps_Repo_Structure for begeinner(Scaffolindg)
DanialHabibi2
 
Hashing Introduction , hash functions and techniques
sailajam21
 
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
Arduino Based Gas Leakage Detector Project
CircuitDigest
 
Ad

Php Basics part 1

  • 2. Setting a Cookie setcookie("user", "Tom", time() + 86400, "/"); // check syntax for function params • Creates a cookie with name user • (Optional) Value of the cookie is Tom • (Optional) Cookie will expire in 1 day (86400 seconds) (Optional) Cookie is available throughout the whole website / • (Optional) Cookie is only sent over HTTPS • (Optional) Cookie is not accessible to scripting languages such as JavaScript
  • 3. Checking if a Cookie is Set if (isset($_COOKIE['user'])) { // true, cookie is set echo 'User is ' . $_COOKIE['user']; }else { // false, cookie is not set echo 'User is not logged in'; }
  • 4. Removing a Cookie setcookie('user', '', time() - 3600, '/'); Or unset($_COOKIE['user']);
  • 5. Retrieving a Cookie echo $_COOKIE['user'];
  • 6. cURL is a tool for transferring data with URL syntax. It support HTTP, FTP, etc
  • 7. a little script check is the cURL extension loaded or not if(!extension_loaded("curl")) { die("cURL extension not loaded! Quit Now."); } // Actual script start // create a new cURL resource // $curl is the handle of the resource $curl = curl_init(); // set the URL and other options curl_setopt($curl, CURLOPT_URL,"http://www.example.com"); // execute and pass the result to browser curl_exec($curl); // close the cURL resource curl_close($curl);
  • 8. Session data accessible across the various pages of an entire website is to use a PHP Session
  • 9. • Start session session_start(); $_SESSION[user'] = ‘gptUser123’; • Destroying Session unset($_SESSION['counter']); session_destroy();
  • 10. ? 1. what id diff b/w session and cookie 2. where you use cookie 3. what is the use of session in your web page 4. have you know any cURL equal method