SlideShare a Scribd company logo
3
Cookies
• HTTP is a stateless protocol; this means that the web server does not know
(or care) whether two requests comes from the same user or not; it just
handles each request without regard to the context in which it happens.
• Cookies are used to maintain the state in between requests—even when
they occur at large time intervals from each other.
• Cookies allow your applications to store a small amount of textual data
(typically,4-6kB) on a Web client browser.
• There are a number of possible uses for cookies, although their most
common one is maintaining state of a user
Most read
4
Creating cookie
• setcookie(‚userid", "100", time() + 86400);
• This simply sets a cookie variable named ‚userid‛ with value ‚100‛
and this variable value will be available till next 86400 seconds
from current time
Cookie variable name
variable value
Expiration time.
Most read
8
Sessions
• Session serve the same purpose of cookies that is sessions are used
to maintain the state in between requests
• Session can be started in two ways in PHP
1. By changing the session.auto_start configuration setting in php.ini
2. Calling session_start() on the beginning of each pages wherever you
use session(Most common way)
Note: session_start() must be called before any output is sent to the browser
Most read
Introduction to PHP
Web programming
Week 11, day2
Cookies
Cookies
• HTTP is a stateless protocol; this means that the web server does not know
(or care) whether two requests comes from the same user or not; it just
handles each request without regard to the context in which it happens.
• Cookies are used to maintain the state in between requests—even when
they occur at large time intervals from each other.
• Cookies allow your applications to store a small amount of textual data
(typically,4-6kB) on a Web client browser.
• There are a number of possible uses for cookies, although their most
common one is maintaining state of a user
Creating cookie
• setcookie(‚userid", "100", time() + 86400);
• This simply sets a cookie variable named ‚userid‛ with value ‚100‛
and this variable value will be available till next 86400 seconds
from current time
Cookie variable name
variable value
Expiration time.
Accessing Cookies
• echo $_COOKIE*’userid’+; // prints 100
• Cookie as array
– setcookie("test_cookie[0]", "foo");
– setcookie("test_cookie[1]", "bar");
– setcookie("test_cookie[2]", "bar");
• var_dump($_COOKIE*‘test_cookie’+);
Destroying Cookies
• There is no special methods to destroy a cookie, We achieve it by
setting the cookie time into a past time so that it destroys it
–Eg : setcookie(‘userid’,100,time()-100);
Sessions
Sessions
• Session serve the same purpose of cookies that is sessions are used
to maintain the state in between requests
• Session can be started in two ways in PHP
1. By changing the session.auto_start configuration setting in php.ini
2. Calling session_start() on the beginning of each pages wherever you
use session(Most common way)
Note: session_start() must be called before any output is sent to the browser
Creating and accessing session
• Once session is started you can create and access session variables
like any other arrays in PHP
– $_SESSION[‘userid’+ = 100;
– echo $_SESSION*‘userid’+; //prints 100
Session variable name variable value
Destroying session
• There are two methods to destroy a session variable
1. Using unset() function
• Eg unsset($_SESSION*‘userid’+)
2. Calling session_destroy() method. This will effectively destroy all the
session variables. So for deleting only one variable you should go for
the previous method
• Session_destroy()
Comparison
 cookies are stored in the user's
browser
 A cookie can keep information in the
user's browser until deleted by user or set
as per the timer. It will not be destroyed
even if you close the browser.
 Cookies can only store string
 we can save cookie for future reference
 Sessions are stored in server
 A session is available as long as the
browser is opened. User cant disable the
session. It will be destroyed if you close the
browser
 Can store not only strings but also
objects
 session cant be.
Cookies Session
HTTP Headers
Headers - Redirection
• The most common use of headers is to redirect the user to another
page. To do this,we use the Location header:
Eg: header("Location: http://phparch.com");
• header() must be called before any other output, including any
whitespace characters outside of PHP tags, as well as all HTML
data.
• If you fail to abide by this rule, two things will happen: your
header will have no effect, and PHP may output an error.
Questions?
‚A good question deserve a good grade…‛
End of day
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com

More Related Content

What's hot (20)

UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES	UNIT II 	LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
Kathirvel Ayyaswamy
 
C - String ppt
C - String ppt C - String ppt
C - String ppt
Md Razib
 
Binary tree and operations
Binary tree and operations Binary tree and operations
Binary tree and operations
varagilavanya
 
Lecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structureLecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structure
Nurjahan Nipa
 
ASP.NET-Web Programming - Sessions and Cookies
ASP.NET-Web Programming - Sessions and CookiesASP.NET-Web Programming - Sessions and Cookies
ASP.NET-Web Programming - Sessions and Cookies
baabtra.com - No. 1 supplier of quality freshers
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
anooppjoseph
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
Pranay Neema
 
Presentation on the topic selection sort
Presentation on the topic selection sortPresentation on the topic selection sort
Presentation on the topic selection sort
District Administration
 
1.8 discretization
1.8 discretization1.8 discretization
1.8 discretization
Krish_ver2
 
Xml namespace
Xml namespaceXml namespace
Xml namespace
GayathriS578276
 
Data mining :Concepts and Techniques Chapter 2, data
Data mining :Concepts and Techniques Chapter 2, dataData mining :Concepts and Techniques Chapter 2, data
Data mining :Concepts and Techniques Chapter 2, data
Salah Amean
 
Notes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queueNotes DATA STRUCTURE - queue
Notes DATA STRUCTURE - queue
Farhanum Aziera
 
Stored procedure
Stored procedureStored procedure
Stored procedure
baabtra.com - No. 1 supplier of quality freshers
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
أحمد محمد
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 
K-Means Clustering Algorithm.pptx
K-Means Clustering Algorithm.pptxK-Means Clustering Algorithm.pptx
K-Means Clustering Algorithm.pptx
JebaRaj26
 
Webservices
WebservicesWebservices
Webservices
Gerard Sylvester
 
Mysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlMysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sql
Aimal Miakhel
 

Viewers also liked (20)

Introduction to php web programming - get and post
Introduction to php  web programming - get and postIntroduction to php  web programming - get and post
Introduction to php web programming - get and post
baabtra.com - No. 1 supplier of quality freshers
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web Programming
Ahmed Swilam
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
baabtra.com - No. 1 supplier of quality freshers
 
PHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and SessionsPHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and Sessions
Vibrant Technologies & Computers
 
Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
www.netgains.org
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
Muthuselvam RS
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
Manish Bothra
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
Coding In Php
Coding In PhpCoding In Php
Coding In Php
Harit Kothari
 
Php Coding Convention
Php Coding ConventionPhp Coding Convention
Php Coding Convention
Phuong Vy
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Zeeshan Ahmed
 
開始網站設計
開始網站設計開始網站設計
開始網站設計
James Shieh
 
MySQL資料庫設計規劃與phpMyAdmin
MySQL資料庫設計規劃與phpMyAdminMySQL資料庫設計規劃與phpMyAdmin
MySQL資料庫設計規劃與phpMyAdmin
James Shieh
 
PHP an intro -1
PHP an intro -1PHP an intro -1
PHP an intro -1
Kanchilug
 
Php ssession - cookies -introduction
Php ssession - cookies -introductionPhp ssession - cookies -introduction
Php ssession - cookies -introduction
Programmer Blog
 
PHP Comprehensive Overview
PHP Comprehensive OverviewPHP Comprehensive Overview
PHP Comprehensive Overview
Mohamed Loey
 
Php course-syllabus
Php course-syllabusPhp course-syllabus
Php course-syllabus
Himanshu Himanshu
 
AI Chatbot Service Framework based on Backpropagation Network for Predicting ...
AI Chatbot Service Framework based on Backpropagation Network for Predicting ...AI Chatbot Service Framework based on Backpropagation Network for Predicting ...
AI Chatbot Service Framework based on Backpropagation Network for Predicting ...
James Shieh
 
Pakistan's mountain ranges
Pakistan's mountain rangesPakistan's mountain ranges
Pakistan's mountain ranges
tehseen bukhari
 
Ad

Similar to Introduction to php web programming - sessions and cookies (20)

Lecture8 php page control by okello erick
Lecture8 php page control by okello erickLecture8 php page control by okello erick
Lecture8 php page control by okello erick
okelloerick
 
Sessions n cookies
Sessions n cookiesSessions n cookies
Sessions n cookies
baabtra.com - No. 1 supplier of quality freshers
 
PHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSPHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONS
Degu8
 
PHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptxPHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptx
ShitalGhotekar
 
FP512 Cookies sessions
FP512 Cookies sessionsFP512 Cookies sessions
FP512 Cookies sessions
Fatin Fatihayah
 
4.4 PHP Session
4.4 PHP Session4.4 PHP Session
4.4 PHP Session
Jalpesh Vasa
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Web app development_cookies_sessions_14
Web app development_cookies_sessions_14
Hassen Poreya
 
Session,cookies
Session,cookiesSession,cookies
Session,cookies
rkmourya511
 
PHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdfPHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
Cookie and session
Cookie and sessionCookie and session
Cookie and session
Aashish Ghale
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
Harit Kothari
 
Session and cookies ,get and post methods
Session and cookies ,get and post methodsSession and cookies ,get and post methods
Session and cookies ,get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
Manish
ManishManish
Manish
Manish Jain
 
Cookies and Session
Cookies and SessionCookies and Session
Cookies and Session
KoraStats
 
4 php-advanced
4 php-advanced4 php-advanced
4 php-advanced
Achchuthan Yogarajah
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
Kamal Acharya
 
lecture 13.pptx
lecture 13.pptxlecture 13.pptx
lecture 13.pptx
ITNet
 
Sessions in php
Sessions in php Sessions in php
Sessions in php
Mudasir Syed
 
Lecture8 php page control by okello erick
Lecture8 php page control by okello erickLecture8 php page control by okello erick
Lecture8 php page control by okello erick
okelloerick
 
PHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSPHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONS
Degu8
 
PHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptxPHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptx
ShitalGhotekar
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Web app development_cookies_sessions_14
Web app development_cookies_sessions_14
Hassen Poreya
 
PHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdfPHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
Harit Kothari
 
Cookies and Session
Cookies and SessionCookies and Session
Cookies and Session
KoraStats
 
lecture 13.pptx
lecture 13.pptxlecture 13.pptx
lecture 13.pptx
ITNet
 
Ad

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
baabtra.com - No. 1 supplier of quality freshers
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
baabtra.com - No. 1 supplier of quality freshers
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
baabtra.com - No. 1 supplier of quality freshers
 
Blue brain
Blue brainBlue brain
Blue brain
baabtra.com - No. 1 supplier of quality freshers
 
5g
5g5g
5g
baabtra.com - No. 1 supplier of quality freshers
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
baabtra.com - No. 1 supplier of quality freshers
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra soft skills
Baabtra soft skillsBaabtra soft skills
Baabtra soft skills
baabtra.com - No. 1 supplier of quality freshers
 

Recently uploaded (20)

FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Data Validation and System Interoperability
Data Validation and System InteroperabilityData Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdfWar_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptxFIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptxFIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Analysis of the changes in the attitude of the news comments caused by knowin...
Analysis of the changes in the attitude of the news comments caused by knowin...Analysis of the changes in the attitude of the news comments caused by knowin...
Analysis of the changes in the attitude of the news comments caused by knowin...
Matsushita Laboratory
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Introduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUEIntroduction to Typescript - GDG On Campus EUE
Introduction to Typescript - GDG On Campus EUE
Google Developer Group On Campus European Universities in Egypt
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptxFIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdfArtificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Data Validation and System Interoperability
Data Validation and System InteroperabilityData Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdfWar_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data ResilienceFloods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptxFIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptxFIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Analysis of the changes in the attitude of the news comments caused by knowin...
Analysis of the changes in the attitude of the news comments caused by knowin...Analysis of the changes in the attitude of the news comments caused by knowin...
Analysis of the changes in the attitude of the news comments caused by knowin...
Matsushita Laboratory
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too LateKubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptxFIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 

Introduction to php web programming - sessions and cookies

  • 1. Introduction to PHP Web programming Week 11, day2
  • 3. Cookies • HTTP is a stateless protocol; this means that the web server does not know (or care) whether two requests comes from the same user or not; it just handles each request without regard to the context in which it happens. • Cookies are used to maintain the state in between requests—even when they occur at large time intervals from each other. • Cookies allow your applications to store a small amount of textual data (typically,4-6kB) on a Web client browser. • There are a number of possible uses for cookies, although their most common one is maintaining state of a user
  • 4. Creating cookie • setcookie(‚userid", "100", time() + 86400); • This simply sets a cookie variable named ‚userid‛ with value ‚100‛ and this variable value will be available till next 86400 seconds from current time Cookie variable name variable value Expiration time.
  • 5. Accessing Cookies • echo $_COOKIE*’userid’+; // prints 100 • Cookie as array – setcookie("test_cookie[0]", "foo"); – setcookie("test_cookie[1]", "bar"); – setcookie("test_cookie[2]", "bar"); • var_dump($_COOKIE*‘test_cookie’+);
  • 6. Destroying Cookies • There is no special methods to destroy a cookie, We achieve it by setting the cookie time into a past time so that it destroys it –Eg : setcookie(‘userid’,100,time()-100);
  • 8. Sessions • Session serve the same purpose of cookies that is sessions are used to maintain the state in between requests • Session can be started in two ways in PHP 1. By changing the session.auto_start configuration setting in php.ini 2. Calling session_start() on the beginning of each pages wherever you use session(Most common way) Note: session_start() must be called before any output is sent to the browser
  • 9. Creating and accessing session • Once session is started you can create and access session variables like any other arrays in PHP – $_SESSION[‘userid’+ = 100; – echo $_SESSION*‘userid’+; //prints 100 Session variable name variable value
  • 10. Destroying session • There are two methods to destroy a session variable 1. Using unset() function • Eg unsset($_SESSION*‘userid’+) 2. Calling session_destroy() method. This will effectively destroy all the session variables. So for deleting only one variable you should go for the previous method • Session_destroy()
  • 11. Comparison  cookies are stored in the user's browser  A cookie can keep information in the user's browser until deleted by user or set as per the timer. It will not be destroyed even if you close the browser.  Cookies can only store string  we can save cookie for future reference  Sessions are stored in server  A session is available as long as the browser is opened. User cant disable the session. It will be destroyed if you close the browser  Can store not only strings but also objects  session cant be. Cookies Session
  • 13. Headers - Redirection • The most common use of headers is to redirect the user to another page. To do this,we use the Location header: Eg: header("Location: http://phparch.com"); • header() must be called before any other output, including any whitespace characters outside of PHP tags, as well as all HTML data. • If you fail to abide by this rule, two things will happen: your header will have no effect, and PHP may output an error.
  • 14. Questions? ‚A good question deserve a good grade…‛
  • 16. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  • 17. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Start up Village Eranakulam, Kerala, India. Email: [email protected]