0% found this document useful (0 votes)
81 views26 pages

WT Assignment 1

The document discusses the differences between GET and POST methods in web programming, highlighting aspects such as data visibility and security. It also explains cookies, sessions, and the HTTP protocol, including how to set, access, and delete cookies in PHP. Additionally, it touches on web servers like Apache and Nginx, and the concept of SSL for secure data transmission.

Uploaded by

asmitananaware02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views26 pages

WT Assignment 1

The document discusses the differences between GET and POST methods in web programming, highlighting aspects such as data visibility and security. It also explains cookies, sessions, and the HTTP protocol, including how to set, access, and delete cookies in PHP. Additionally, it touches on web servers like Apache and Nginx, and the concept of SSL for secure data transmission.

Uploaded by

asmitananaware02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

AssingmentNo-o

Page No.

Tnternal Date
programming
State differencebetdeen GET
and Post method
GET
PosT
Retve data fon 2).Sends dota to a Seeue)
to
Sele Ceate or ipdate e Soyrce
2) Valuel are Visible
joVeluesdre
not visib/e
theURL in
the uRL
)Spperte3ing
datatpes
3)Suppartsdifkrent
data
,suchaj string
typesaf

qndbindny inumuc,
4Jess Se cure because ) Moe Secure because the dat
thedataisexpesedin is not expsed in the URL bae
Hhe uRL bar
5) Useed for Seanching,S)
used tor subrajttia
forms,
Hlkxing Pagig madibyinq doctas n Ceating
ne eSOurces
w
6 Veyoftencalheable6)
Haxly Cacheable

.3.what is Cook ies ?

)A Cackie is asmall
piece of dat in the ferm ofa
name-Valye pajc that is Sent a web Seve qno
Saredby thebnwse on the client
machine.
R PHP ceckie isa Small pieceof intormafiy
whichis
stored at clientbrowse,
Tis ugcd tatecagnjze
the
usel.
3)Syntx
kie Coamel,Value lyepireC,path
Ls do moinC,

Se Cure]JJ]]);
4)Examplel
tosetCaokie in
inone Page !
PageNo.
Dete

SetcaakieC "TD*,");
setcaakie"hame", ");
"Laptop

-canbe acessin anothcePaqe as tollouds


C9 PhP
ifCis
set
echoProduct
C"TDD)F
($-CeokIE

echo "productAame
ID;-"IDJ:bry"CookTE
!",g_CookIEC"name ]5
C

else
echo

Explio in detai Conept af Se SSlans.


9DA Sessih Can be define as "a Seielof nelate
interactens
betueeni asingleclientand the ues Seive
which takes place ove a pegod af tine?
e) Sesjo
allo)you to storedota in he b see
that 135ociated wjth a seSSjenTD.
Once ycuCate
C
a Sessfen ,PHp Sends caa Kie a tht Containgthe
Sesssan ID to the web bpuuse
3)PHPSessjn toshreand pgs infymeti
|)
s uSe
fom Page to anothee em
me
Poany
PHP Sessjao-statfunctes hsedto stat
the
-apewarreumeg eusingSessin
Sessionif&ssicn is coeategahcadl
esishrg
Tt seSslon s hot aveilablet
CYeates dnehms
new Sessi
Sqntar bool sessn.Stat)
$-sEssTONisan asSejahrearaythatContainsal
Session Vanabe t Is use to set and get SesS/n
Vanable Value.
6) Make use af issett)
fctient
Vatiabe check Sesses
a dest php tile ndlocscl h fle
o 5ee he reSuH. rmanythishine
3 Exanple
29 PhP
Sessio-5attu:
fisset
($-SESS
1oN C'Count))
$-SESSIo C'Countes'+=
elsef
=1;
$-SESSToN C'lounteJ

$msg YouhaveVisitce+his
Page". SE SSIoN C'ountes]
"inthssessjon"
<Htmi}
Zheadt
<HHe? Sehg up a PHp Session Uhitte)
cbedys

lbody
29 Php echo (s mg))
21html)
How to accessdata in the
Sassn?
unlike a Ceokje,we can shre any typedat data is
jou star data as ke ys gnd Values n the 5SESSToN]
bal
Supesglo
arvay
foy
taample'- inthe
aod roled
ndes.hp file,e
Store uie2 she

aTay ih the Se ssiag laus


ag fal
29php
Sessjeo-
Stait)}
-SESSIoN 4se7"adnin
PageNo.
Date

$nles=
array"admia'
"appnve 'editor"
SE SS IoNC'les nles
Se ssim-wite-close)
hreftestl.
a Php") to PotePage la Go

Tn the PAle:Ph fle,


follous '
you Can access Se SSic o

Sessjon-statt)
Cssets SESSIoNC'uSeJ));
ec ho
SpriotfCwelo .sLbr-SESSme
IOA|C'useg
ifCissetsEsS TonColes]))
écho 'oles 'implocks-SESSTON
SpoottYous
C'oles']')

Destny a pHp sesslen'


To e
move
the essido USe
glabalSesSienVasablesand dsdestoy
Sessn-unset( and
functions
Hee,is
A
ho
PhP
exqmple to dnse

unset ($-SESSlO
asingle
Vanable '
C'Coynter

Hae,
lsthe cal hich wlldeshyalLthe
Php SossJenVeaziable

Sessien-siaet)

<hdy
29 PhP
echo "Altses5ios
Vaable are ho
w
PageNo.
Date

and the Sessini'sdeshoyed"

zlhaly
lhtm

hat s sickyform Q

Khawn.as shekyfosmo.
techniue
In stickyformsthevaluesentet
Ln e by uselato
emaindisplaye f.
with the torm CamPone ht,ifwe
the form af ter S ubmt
displat
aSwhat is HTTP9
HTTP is Hypestext pntacol
Transfes isa stakless
pnbcal
HTTPSuppets my request pe Conne ctjen.
bis heans that wih HTTP the client Cennectsta

the Seveg ta send me eguestand then discnnet

Explainio detailthe conCept of Cockieg


coakje is a Smas! Piece ofinfarmatian
3toredasa file
in the user's bmuse) by the webSeue2,onceCreat
Cook ie Sent to theweb Serve as beades iafor
hmatan with eg eveny
HTTP eguegt.
User Can use Ceckieto save any data but t Shoukd oat
ex Ceed Ik(l0 in Size.
24 bytes)
Ypes af Cookies!
Sessian Ceokie' Tbisype of caokie qre temporay
and d re expie as soan a the Sesseo ends ntbe
bwsel clased.
PerrSistent Cookie - To make aCoakieporsiskn
sato
e

must prVide t ith an expiratiotime,TEenthe Coakie


wi ime,
expiedfteythe qirenexpiratin
mly
untlhenjt wj)be Valigd Coakje. a
Page No.
Date

acodieinPHP
xeting
Syntax
SctceskieCname, expire,
Value, path,damain,Seau-
The firstasgunmen which cletne)
the hame of
Cockie is mandaton,reSt allaN aphoal argumen
Lt wc wa fo C ate aCookle to Store the
hame
af the usei whe visikeeyoul uebsike,
andseton
epiration me of week then we Can do tL'ko
his

Setockie
(' usesnme ","am time)
abbishek, t6ot6otat
9
loaccess a stored cockjewe use the BCook TE
glabul
Vaable,and can use the sset)method ta check whether
the coekie is Set or nat.
Etample'
29 PhP

Setookiel''usesnarme tine)
iamabh'shek'' +
6ot6ot);
2htmi)
Zbody
PHP

fsset(3.CookTE
C"
"useename))
echo "Cookieset wjth
Velue$_CookIE
C"usegname
3elsef
echo "Ceokienat set";

<lbody

F we want
|
pdeting Coakiein pHp
lo updte modihy acokie,
updot
Simp)ysetis guth
the use2ngne Sted i the(ookie
foxc ple
ected abeye,
20fhp
e can da ituaing seteokr)
methadaaio

usemame"
Settookíid" TamAlohhishek,
time t6ot6tae):

Zhtmi)

fFs IEC"usezhame']))
setC8-CooK
echo"ookie
Set with Valye;"$-
CookIE ' usatname]:
3elsef
"
echo Cookie nat Set

2) body
Zlbtm.
To update the Valdeof useTnamececkie from iamabhshekt
TarmNoTabhishek.
Deletea Cookie inPHP.

o deleteomoe a cookie,
we need to expine the Cocke
wbích Can be
done by wpdating the cockie usingthe
setcookie0functon with ezpirticn data inpst.

amotabhishek',time)-36
Stcookie'useghame"a"i ae),

<htmi
Lhedy)

echo "Cookie ws ete|


ehame is del

2lbods
<\btm!}
Pege No.
Date

G)ahat is Eplainit woth erample.


hcky foxms
any ceb Sitesuseatechhique khaun
sticky
tor
Tn
Sichyforms the Value enere by
disphyed wth the form Camponent,t we

thetorm aftte2 Submjt displag


For example'
Tt we Search ChttPslnwgaogle
qooqle (om)for
"pH.
lCaakboak"the top af the reSult page Carotainsqnathe
Scasch box, whichabead y Cotains
"PHP Cookb ogk" To
efe
ofine he Sesth to"PHP Cookboakfom
O'Reilly"
Can simply add theexta key cds.
Caasidez he follauaing
kywad
Example
Lhtmly
}Greet
heady2itle U Se lHHeyheads
Lbedy)
form4eion:9PhP
echo 6_8ERUERC' PHP SELF101
mehod="GET">
Ente You name
Cinputtype="tet"
2jnput yPe =
name
'submit"
namtt")
br }
Llform)
Tfusse
(9-GET'namel)E
$hm $-GETL'hame];
echo 'Hello
"'.
$hm.
3

2lbody
zlhtmi).

QgGie at twaQamples
least of web Seruel
Apache HTTP Senles
APAche HTIP 3erVC)s
me gf the mast uidelgused
Psge No.
|Bats

t is an.
mastopen-SourceCDsS-platform
Sexvezs
Sexve2 Hhat Suppats aide ange dt Peraingsyster
khe
and Linyx.Apache
inchidingwjndoes, macaS,
anelreliabi
Scalabllihy
foeitsttezbitity
liy.
2)Ngínz isanothe popukasweb
Noinxprohaun ce "engtne
-%")
ad CmgS -plotform,
Se)veiTt s aso open-GouTce
apen-
and
supatingoperatingS ystem ikeeindousmacos
inuz Alqihz is khoun foritshigh pertImance.
Scelabiitand esSauree usage.
check Vagableis Set
whethes q witha Sessico 9

89Hos to
>e hae Stataasessoand Set two sesSin Vanables
aso havealink havigateto
oill
Abavewebpaqa
Se coad Page SecondaPage.phP
Je the tor SecoodPage.
Code phpinohich we feteh
Values fomthe Sessjon Vaiiable
cwbjch
the tirstpage.phP

SessjoStact)
SusendmeS_ Sb SSTON
= usename C y

= $-sEssLON C'uSeejdJ;
Suseiid

echo Muge hame is "$


wselname, Lb)
)
2)body
Ceho ugegidis".Buserid
PageNo.
Date

Q. lo-|ste
Shot hote on SSZ
SsLCsecure SacketLay ez) is Crypqrapbie
behuee
Cem aunftatioo
uSe ta pnujde se cue
web bmuseana seve) a weh
SmHed betweenthe br
SSL emlnyps dota tan booese
andSegvel unremclahleta unauthas'ze
makingt
Patie.
SSVesibsthe af the Serue ahal
thatthelota
iscaming
enSuse hatthe detatanSmiteis nat
tampeged th or aterca tranSnmisSian
SS en Sures that Sensie Such as fasswe
do amd cseditcard numbess ar transmtted
secrel
SsL helpsto tablish tst
and Cedihility
with
websie isitrs
.l•tePHP a Soiptto actept two Stsng an checks
ar equel ulingstickyforn
F(5-SERVERC'REQUST_METHOD=lPosT)
stingi
= trim(9PosST
L'string:

lTbe
3else stingsam equal

Sme 3sage Tbe

gsbinglvalue-
isset
4-fo
ST L'Stningi)2
SstoeValuezisset(4_PosT a1)
C'stnag
g-PosTStrTngoJ;
PageNo.
Date

2form action method Pas"


Llabelfor2string")Enterirst
string llabely
sinputtype=teFd'stngi"
name "
Value' phP e cho sstinglNalue,9>
cbr
label fr'shinga Entesseood
id's trinsa"
strhg: IBabel?
nameeAPh
inputtype=tet'" oho

input tpe "sLbmit" =compan


Value
ltosm
9phP
E Cisset(sme35age)
echo q me 9Sage

Q2istany two pHP HTTP funatHoo


>) $-GET 3)heade2)
l)3-
Pos T

Can
yau aSSociate avagiableaitha SessjanP
ASsaciate a Vamable with Sessinusing the -SEsSToN.
supexglobndaray
a SeSsjn
Saxting a

You needstast Se Ssion Lsingthe


to

Sessim staitOfunchen
Se SSion~Staia
Setting a &essonyazlable assocjatea vaniable.To w

in yau Can agsiqoa valuetothefSESSTONQ9Ta


a sess

$-SESSIaN IVanablename']:Value'
Accessing a JessienVanableto acceSsthe bdue of q
Sessian Vanable you an s inpy elethe9-SESSIoN
Cho SESsIoN
CVasablenam's
PageNo.
Date

Sessin-staztO,
$-sESSIa 'Seg
ngme-iohodoe
lecha'wdcanne - SESSIa T' uSes name ]
Qpkio
AExpkin in detallfle pload witheample
In pHp t handlg tile upleads,
J-EILESGTa is
used he ele me nt af the$FLEs
I)ES acaygikesiatr
mation abauttheuplaadfle
name name af he tle,
e as
bythebnse
Supplied
h

$FTLE
Tpe =h
$ -FILE
C'Hlename7'hame]
typeaf the uelaadedfik.
L'6lengm]
egiimagelip
[type'
size be Size of the uplaad fileCin bytes),
Ifthe
uses attemped to upacl a flethet was toolarge
the Sie
isrepasted as o
$FILE L'Hlename'JCs)ze
tmpnamehehame of he te mpora f ile o the
Serez thut halds the uploadeof'le.
TF the usey
attempto to uplaad a that was toalasge le
e
name is repote as lnone"
$-FILEUflenamelCtmp-
name]
Enr he emr Code
Cade 6
esl fomthe uploasedl
fle & hing

$-[rLEL'H
lename7Dexor7
To test whehe afle was successhly
not use the functio caplaaded
ffis íouploadedtile),as
loas
ploasleo file($ELLEs
T'flenameTtmp hame

Ales are stordin the


Servers defeult
tempa ay
Gles irtag which I5 specitesinphP.
|the pload tnP-dir aption ot with
PagsNo.
Loate

ample file.
uplocdhtml
Lhtm titeFile uploallHHe;
Zheady
cheady

_MPos
"uploa-php?methcd
bacm achen =

lfornm-data"y
-^multipast
enctype
seectfle
hame-le
To Wplaad
laaclTmage" name='Sb
Value "UP
type "'Sebmit"
<inpt =

-
uploadphpfle
L9Php
$taxqet-Path"E|" T'fleToUPlom l2
basename$-FILES
$tanget-Pathaget-path.
ClnameD
Touplaad C'tmphane2
C'Ale
fCmove-uploaaesl-AlelFFILES
$ toget-Path))
echoFileuptaade ucce9sfuf

uploase,
Plecsse y aga n!"
echo Msomy, file het

gis Listthe elementsof$SERVER


21) -SERVERC'PHP-SELF'
C'GATEAyINTERFACE]
2)-SERVER
3) $-SERVERC'SERVERADpR
$sERVER C'SERVERNAME'J
4)
S) $-sERVERCSERVE SoFTWWARET
R

) $-sERVERLsERVERPROTocoLJ
67)9-SERVERREguEST-METHOD'J
99-sERVER[REguFsT.TIME
PageNo.
Date

DuERY-STRING
q)$-sERVER
lo-sERVER T'HTTP_Acc EPTJ
$-SERVERCHTTP-AcCEPT-cHARSETJ
13)$-SERVER C'HTTP HasT']
3)$SERVER C HTTP_ REFERER'Y
D4) $ SERVER C HTTPS]
IS)$-SERVERCREMoTE_ADDA
$-sERVER'REMoTE-Hos
|l6) TJ
)-sERVERC'REMoTE_PoRT'
8)$-SERVERD^CRTPT-
FILENAM EJ
l9>$_sERVERSERVER-ADMIN']
P _sERVER 'SERVER PoRT'7
21,$-sERVER
D'SERVER_sIGNATUREI
22)$-sERVER'PATH-TTRANSLATED)
3)sSERVERC'scRI
PT-NAMEJ
24) $-sERVER'sCRIPT URIJ

Swhat is
Q. use of $HTTPaakIES_VARS.P
|$HTTP_CookIES VARS is deprecate PHþ vajable
q
that
was. Used to access It
cookie. was ah asSO ciahe
armaul
that ootaine the Valueyaf Cookies sent by the
cdient
Example
echo $HTTPs CookIE VARS C'Coakiename
G.ITwhats use of $HTTP_GET VAS 9

s
$HTTP-ET-VARS a depre cateo
PHP aliable uas tht
used t
acceSs Vaiables
PasSea throughthe HTTP tT
method
Example'
echo $HTIPeGET
VARSVandblehame',
Page No,

Dats

is use of $HT TP-PoST FILES


&.ahat
4HTP -PosI-E1TESisadeprecate PHp Velable d

twasusedtomeacces fileuploade 4hnugh S

aample
echo
'thod
the HTTP posT

HTTE_ PosT C'hameJ:


fILESL'fleJ

the purpose of
S ENV.
19)state de precatedvaiidble thatwas used t
$ENV
acceSs onvinamentVarables
of $Ey
$Ev waS to pvidea
Thepuxpese of way to

which are vanables


accessenvinnment Variable
thatae set outside af thePHp 3aipt,typicalty
or the wch Seave.
by the operatingsystem
Eple Example
echa $ENV C PATH'J

G.2e List thevaiable aaf HTTp fileuplod


3FILES 'Gle]['name
T

3) s-FILEs 'Jc'ype']
['Gile
-FILES
3) CAle'IC'sjze'7
)$-FLESCh le]L'temP hame']:
C'FleJC'er
S $-FILES

State the purposeof $_REQUST


T-REQUES iS a Supe2globalarrag that comtans the
Contegts of the $GETs_posT, dneF_CoakIE mrayi.
Abe prposeof gREQU EST is o poVide
ConWenient ta aelsequest methed eed

0.22
ExplainallSuperglobal
Waiable
s
Wajable PrdefnedVagfablethad
Superglabal ae
are aw s acçe
a essible of the Scape
re4arelless
PageNo.
Date

9GLoBALS!The LOBALS anray Ceontaiag


reterence
to cll Vaciableythat dre Cureaty efine is e
globalScape
)$-SERVER!-
The $-SERVER amay cootains
ioforma
abot the Ses Veg and the cuneat quest,Suchays
•Seveg name dndpart
ete).
Request methed_ CoETPoST,
*RequestURI and queny sting
• HTTp
beadeg.
3)s-GETThe $-GET axray ContainsdatuSentto
the Senpt Via the HTIP GEI bmethod.
42 9-PoST The S-PosT aYray Contans alataSentt
the Soipt vìa the HITP PosT methad
5)$-FTLES-Tbe $_TLES arTay cotainsnfarmatin
to tha Sogpt uia the HTTP As
about filesuploaalel
mthecd.
ls$-CookIE The g-cockIEamay castainsdty
Stored athe dest Side Caakia9 ay

$-ESSIOM-The $-SESSTON amay Cosataiadat


shreelthe Sezve9-sideal essep vagahles
Is>-
REOUE SEe gREQUEST aayCoataiag
data sent to the Scspt Liathe HTTp GEIposT,
g>$-ENVi-The gENV aray contaAg envinnment
Vasablej Setoutsle
af PHP,

Q.23.tite
te na elf pmesshg Tor,
an
A sin4le PHP program Can
be uselto bath qencale
a form dnd pnle3s
ittusing Cambinatagaf HTML nd
pHP bìshpe of PHP Paqe is
knaan ag selfpne3Sl
Page
we cao wnte a pgam uhichcn de cdowhethe
adisplag
a formatPhreIs
H depenelingmhe
Page No.
|Date

pasamete has been supplíc ar not


One

For exple
<htrol)
heaedykHHe eat usee 2 ie <lheaJ
< body

ifCsset ( – GET Dhame


fnm SGEI['name
echo Hdlo".$nm
Selsef

Lform detion=Php
echo -SERVERC'PHP ELFA
method'GET
Ente r yow name
<infut ypetet"
name = "name l' <br
<inpt hy pe-'sbmit"
nane = 'ok" )
rm
L1fo

zlbedy

Hou to handle Sessio


stat sesSina

stetasossion,
To usethe se 9sic StalO
flnchen E's
hunetiag must be calle befo e dnyotputitsent b the
bhuses
)y
Sesslenstaet
Setng sessjo Vancbleglo Set a SesslagVanable use
the3SESSIoN Sper globl a
C'Venaable name]='Value
S-SESSlew
nceesSjng Sessin Vaaahle to qcce 9s4 SegsioVaijable
PageNo.
Date

the $_SESSTON Qray


Supexglabal
eho$.sESSIoJ C'Vamablename
Sessiag Vaiialel
4nsetting
lo UnsetSessien Vliable,Use the yh Set )
a

funci
hsets-SESSIos
C'Vanablename
SJbe
lostying Sessfan
deshg a
Session use the Se SsyMdesayUhyn
5isfuncticnwl deletethe Sessie datafoIM4he
SeNe
Sessindesty O

Q2Sstatedifterence
between GET aned poSmeh
GET PasT.
2Datais visible
inVRL leDt hiddenfamthe
s
) LimitddataCapacity asget dato capacy
a) by bpuSep whichaJNot cathedby bhwse
Cached
Can deeelto stale
data.
4) Tdemp.tent, meaningthod|4 Not idempatent, meanig
makingthe Sa me mguest|that makíing the Same reyuest
mlHple fineshas the Lmltple hbel an hae difkeson
Same effects
iton(effectas
e
making

s1 used forretseving
dada
6omthe Seves
6 be questdoes hot
SVel dta
hecify
data an theSeve
The
dats
cquestmedlfies Rl
74ET nequestS are men pasT Tequests Qne mo he

Uneableto CpSS Vylneable


to CoSS -site
sik-Request
forgcey Sapting attacks.
ttacks
Page No
Date

asbat note

Coakie
is
is a at informaHeo
Sallpjece Stored as a

usess hnwse by the eveL ante


weh
fiein the the wehSezve asheades
weh
Sent t
cseatedcockieis s

iofoxmatinwithevey HTIP KyueSt


user an use coskie to Sarednydate bt 4 Shoukd

exeed n size
IkClo24bytes)
Real w
of cookie
use

lTo stoe user ioormatn ke ehen helshe isikea


the webSitesetes
what Pages were Visite o
that next tioe the ugeg Visits yaur aeh Site yau Can
a bette user eipenthe.
ppuide
JTo store basic wwebsite Specihcioformahtntokho
thisis botthe first visit ofuseg
You Can use Cookies t Stare humber of Vsitsoc
Nje Coun ter.
w
Types of Ceokiey
2sesSionCoakie - his tpeof Cookieg
lane as Soan as the Sessn ends r thebhwSe
expire
isclased
istent coakje cookie perSistent
3)Pers To oake a

Cockie we must Paide t witt an tme


expiratisn
Dben the co kie wil expir aftu the qien
n fornatiagor tme uni]the itailL
espitat'on be

a Valíd caakie
CTeatin4PHp ccakie.
expíres puth, domain SouYce)
SetcookieCnamne,Vadue,

in PHP with
theCoctept
O27Eplain of Segsla, handting
Sutableeranmple
s5j Can be de fhinedasla Serses of elate
dat
A Se

betoeen asingle clientaadthe web Seuel


inkraction
which take placeavelapesjod of ime.
S
|PegeNo.
Date

PHP Seasion shet)


funchonis ugead to star he

essiaItstaxts cshgseas
tn huyns estng Sessje af sessiogtseete
ayTÉ Sessian s hat labletceates
avai q

Syntax StutOy
Sessieo-
Hae to accessdata in the Se sspon 2

unlikeacoakie we can 6tore any pes et dat io


Se ssiang youdata a Store keyg and valuesinthe

SESSIOAC] Supeglabal 4sy


frexample,
iathe iadex.phpfile,ue
Store Lses Stne
and roles axa in the Sessie as oleuha

Sesim-Stat(
4-SESSIONC'uSes]"ddmin"
-roley arra C'"adain',lappave'"editar'}
$-sESSIo C'mles']= $-mes
N

Sessinwnteclase O

la href trstt.php"
Ga to pofile
page la
In h Phfle php fle,
you Can access sessindeta
as flous'
29PbP
SesSienStato
ifCisset
(s SESSTosC'uge)
echosintfC^oelCome
Yos! b' SESSTAA'use!
ifCisset(s-SEsSTo roles)) C'

a Spotf('your ness'
Lmpledt sEssZes
C'nles,)
9
Page No.
Date

Self
Self poesStn forms with Sitable
formg erample
Eplaia
ASingle pp
foxms Cen be wsed to bath qeneiate
it, sf HIML
formand Prpcass; wSing Combinahag Self
undPHpJbs type of PHP paqe iskhaw ag

pmcessingpage
4 prgramwhichcandecide helhes
entheone of
aform er phessitdepending
Supplie rnot
the pasametee hos been
farexamplel
htmly
cheadyHhe Grect user<lhHe<lbaady
<body
z9phP
HCs set ($_GETChamel'))F

focaachion:"<qphP
SELE9"
ecka $sERVER C'PHP.

methael -
"GET
Enteryour nane
cinput type
tet hane
Linputtype 'suhmit" hame -lo "2

lbedyy
2lhtml

gwhat i's sticklfna Eplain exa mple.


oith Suitable
many web sites LSe a techiqeskhoun astc
ky oxms,
Tn sHcky forms the Values entesed by usel mqin
e
PegeNo.
Dete

eisplayedwith the tono Component it e displagthe


tosmafterSubomit
le make fong stickI we Cas theSabmíte tr
Valueas the detauttValdechen aatny he HTML

Example
Lhtnl
Ahead)hHe Goeet userehHes2lhea
cbedy
Lformactoo"
9php eeha s-SERUERP'PHP SELF]
hmethed "ET"
Ente Yaw)hame
inpu ype ="QPhPecho
ext"name='hamel"alue

Linputtype "submjt hame-"ak'l


1form
29Php
if set($-GET Chame
CiS ]){
SnmesGET C'hame'l
coho Hello".
Bnm

Hou to egister avanableinh a Sessia


o ngist)avasable
int q SesSheo in PHP,you Can
use the $-SESSIoNSuptaglabal
a aayHeesezample
Se ssínStato
$SESSIoN C'Vajable
-nameJ fusjable
vote
osexample
Sesstet Sessjen stastt)
3usehg me e Joho Dae
Page No.
Dat

T'usename E useshame

Mow.the 3userhame Vanable is eqíste íntothe Segsie

adcanbe accessed on ethe page) e9ing

$SESSToNCuserhamey
ditterentmethacs usedto maintain State DH. o

Explain via the uses


AS we Ppjde input t Some applicahos
fatexface,
we e chanqe the St state of the applicat
the exactCondiho, moe ment to move hent
Stateis
althedetaand Waeiableinthoapplicahon
methade ane -
Some
the
iHddenEields me Se9Sjm tackingtechniqueg sto
bidden form fieldst pas dat fam fields to

So theVluel lable n the $ GET


are avai
Passfjelds
o sPos arays.
2Cookíes bpusp
storedanthe client's
Coekies arc Smalltexthle Such
Shallamontsofdada,
They can be usedto store
TDs.
uses peom preferehces
o SeSSion

ceekes are Sent ottheve HTTS queSt to the

thesenQ
lloinq o access e Stzayedata.
Servel
2sessim'
Sessicndnea way to stiedata on the Seye-Side.
assocjate with a speciticUUSeg
sessinTDs
Uisits a websiteaunigue
lwhenause thecse Is
js qenerate ahc St red ina Coo kie an

bywser.
9) VRL Rewnting Tn echnigue youcan add Seme
Ihthis techhiq
eha inthe URL,
inforaatln
PageNo.
Date

Howue Can get CoGkie Valuesano olesfoy


Cockies
)Get Coakie Value
lo setke à coskie's vale,uSe the CookIE
Speagla
iEissetS
CooKT EL'Cookie-nam))}
$Cook'e-value $CaokIE L'cockje hame]
echoCoakle
Velue $Cockie vales
Belseg
echa
ha "coekieis hat sct"

use the Stcookiel)


funchen with the cooklename
Set the expitation
time ta past stm
tine
Sctceekie
(^Cookienameime)36oo,
unset $-CookIE
1"): M

C'Cookiename)i
ccho Cookie has been deshoyo'

G.33 U'st
thetem
in9_FLES aray.
available
>ame The name of he file as Supied
b the
bmwsec,$-FILEL'h
le name7hame1

Tpe' The af hype he uploadadfile frerample


imageljpcg
2)
'he
si2e S)2e of the uplaadodf le if
the usce
ottemptead
Wag
the S2e is repnted aso
4)tmP name The hame of the tem poan
the scNe fileon
thot haba theeplaaaled
use attempkdto wpJaad a
file,f the
filethatwagta lalges
he hame 5
repott a hene!.
$-FILTHlengmeJ'erm
PageNo.

erne cacde sultingfro the uploaded


m

le
4
Clerr
-FILELflengme']
automathcg lobalVaiables
inPHA List

as fouT.
Vamable in
Auto motieqlabal Ppare prede fioeo
egandlass
alcessible
alluays
global arrays that axe

o4 scape

Contains data event vid the URLuey sting


eg.echo - ET C'name7:
D$PosT
Cootains data sent Va dn HTTA PbsT eguet
often fom torms wjth the meth ="Ps T'"

attbute.
tgecbo 3-pesTusename]
:
3)-FILES
Comtains.infermatiog
about tiles
wp loadeg wia Gn HI
torm.
C'hame7;
C'h)eJ
echo s-FILEs
)sSESSTON '
eoataihssesSjoVassables usel-
to Stainy Specihe
dat acDs multpe Paqel s

eg taet)s
SesSjos-S

echa tSESSIONC'uger']

Q35Ezplaininbef sessianand coakiel.


Se9Sjao.
ASessleois way Stoe dat
a fon
the selve? n

indivi
dual uSeSJusing theirVisitta website.
data peasis Payclnt)
ts acmsshaultiple the
|PegeNo.
Date

Hhe SesSinexpire oc is destyad


Data s streo on the Sevedod a higueSessin
SSent to the client
os q Cookíc ca ia the URL

Sehsitke t ke hseg
leat for stoang authen
staig
hcatioodetails
Eample'
SessipStatO
-SESSION uSerhonelobnDoe?

Cookje
A
as
cekieis mall
bmwsei Tt allous
clients
picace af dat
website to reme mbee
stred m tho

about the uses behoeen visitsor Ses


infornation jon
Data isstaen the cientSde andsenduts
evcny HIIP cquest the Selvel.
for emem heing noa Snsihe
Suitable deta ike
pete
Empe'
ence oytackiy
setcookjeluez
hame'"ohn
Doe",timelt360o,"
echo gCookIELUSes name

You might also like