ENG1003 Lecture Notes - Lecture 7: Data Loss, Unique Key, Json

63 views4 pages
!"#$%&"%'(#')#*'+,-&'."&&',//&%%'*#'/#012*&"3%'.45&'%6%*&0'*#'%*#"&',)('
"&*"4&-&'(#/%
7,)(8#9&( :'4%#5,*&('."#0'*+&'"&%*'#.'*+&'15,*.#"0'4*3%'"2))4);'#)'.#"'
%&/2"4*6
<
Cookies :'(,*,'4)'*+&'.#"0'#.'%0,55'*&9*'.45&%'/#).4)&('*#'8"#$%&"3%'%,)(8#9'
(#$)5#,(&('$+&)'2%&"'-4%4*%'$&8%4*&='*+&)'%*#"&('5#/,556 86'8"#$%&"
>%2,556'4(&)*4.4&% 2%&"'?%0,55',0)*'#.'4).#@'?&;A'%+#114);'/,"*'BC'DDE'2%&"'BC@
<
7&)*'21',%'1,"*'#.'FGGH'"&I2&%*'*#'$&8%4*&'$+&)'$&8%4*&'"&-4%4*&(
<
J#)*,4)'K&6L-,52&'1,4"%'#.'(,*,
<
M404*&('*#'%0,55',0)*'#.'*&9*'?0,9'NK!@
<
O&1*'2)*45'(&5&*4#)'86'2%&"L&914",*4#) ?(&5&*&('86'8"#$%&"'#)'6#2"'
8&+,5.@'DDE'1##"'%#52*4#)%'.#"'$&8',11%'*#'%*#"&'(,*,
<
<
J,)'8&'2%&(=',0#);'#*+&"'*+4);%='*#'4(&)*4.6'8"#$%&"'*#','$&8'%&"-&"
R55#$%'%&%%4#)'%*,*&'*#'8&'0,4)*,4)&('#-&"'%&-&",5'1,;&'"&I2&%*%
Q;A'K&&14);'*",/K'#.'%+#114);'/,"*'4*&0%'$+45&'8"#$%4);'#)54)&'%*#"&
<
Local+Storage/LS
:'%*,;&'RHB'%211#"*&('86'FGSM'T',55'0#(&")'8"#$%&"%
J2""&)*'/#)*&)*%'/,)'8&'&9,04)&('4)'J+"#0&'2%4);'
UR1154/,*4#)U'*,8'#.'C&-'G##5%
<
7*#"&%'4).#'86'8"#$%&"'#)','1&"D(#0,4)'8,%4%
<
M404*,*4#)%V
8"#$%&"%',55#/,*&'0,9'WS!'#.'%,)(8#9&('(,*,L$&8'
(#0
<
X&8'(#0'/,)'#)56'%211#"*'0,)6'$&8',11%'$4*+'
%+,"&('M7
<
S2%*'+,-&'%,0&'(#0'*#',//&%%'%+,"&('M7'(,*,
<
M7'(,*,')&-&"'*",)%.&""&('*#','%&"-&"'2)54K&'/##K4&%<
Y)56'%211#"*%'%,-4);'K&6L-,52& 7*"4);'1,4"%
7*#"&%','-,52&'%*"4);'.#"',';4-&)'K&6='$+4/+'/,)'
*+&)'8&'2%&('*#'"&*"4&-&'*+&',%%#/4,*&('-,52&
<
sessionStorage #8Z'$L'%,0&'4)*&".,/&'?4&'0&*+#(%@'
,%'M7
C,*,'1&"%4%*%',/"#%%'1;'"&5#,(%='82*'#)56'2)*45'
8"#$%&"'4%')&9*'/5#%&(
J,)3*'8&'2%&('.#"'1&"0,)&)*'%*#",;&
<
G#'/+&/K'M7=''Inspect' -> 'Application'
G#'%*#"&'%*+'4)'M7='
'localStorage.setItem("name","Annette")
Cloud+Storage/CS
:'"&0#*&'%&"-&"
>%&"3%'(,*,',-,45,85&',)('%28%&I'0#(4.4&('."0'025*415&'
(&-4/&%L/#012*&"%
<
[&I24"&%'$&8'/#))&/*)<
[&I24"&%'%&"4,54%4);' T'(&D%&"4,54%4);'*#'.,/45'*",)%.&"'T'2%&'#.'*",)%.&""&('
(,*,
<
J#(&'*&/+)4I2&%'*#'%&"4,54%&',)('(&%&"4,54%&'\7'#8Z% *#'%*"4);%',)('8,/KV
JSON (JS+Object+Notation)
:','(,*,'.#"0,*'%*('2%&('&9*&)%4-&56'8&6#)('\7'*#'*",)%04*'%*"2/*2"&('(,*,'
%2/+',%'#8Z&/*'(,*,
G+4%'%28%&*'#.'#8Z'54*&",5' )#*,*4#)'/,0&',8#2*'(2&'*#'*+&'%4015&'"25&%'.#"'
8245(4);'#8Z%'2%4);'\73'#8Z'54*&",5')#*,*4#)
<
]7'\7'#8Z'54*&",5')#*,*4#)V
71&/4.4&(',%'7*"4);=')#*'Y8Z&/*<
C#&%)^*'%211#"*'.2)/*)'1"#1&"*4&%='#)56'(,*,'1"#1&"*4&%<
H"#1&"*6'),0&% 4)'\Y7_'.#"0,**&('%*"4);%'&)/5#%&('4)'UU<
!,%4/'*61&%V
_208&"'D(#&%)3*',55#$'_,_='(#&%)3*'(4%*4);24%+'8*$)'4)*&;&"'T'
.5#,*4);D1*
<
7*"4);'D(&5404*&('$L'UU='%211#"*'L'&%/,14);'%6)*,9<
!##5&,)<
R"",6'D?:',)'#"(&"&('54%*'#.'`&"#L0#"&'-,52&%='&,/+'#.'$+4/+'0,6'8&'#.'
,)6'*61&@'D2%&%'ab'$L'&5&0&)*%'8&4);'='%&1,",*&(
<
Y8Z&/*'
:,)'2)#"(&"&('/#55&/*)'#.'),0&L-,52&'1,4"%'$+&"&'*+&'
),0&%LK&6% ,"&'%*"4);%'?&,/+'K&6'%+5('8&'2)4I2&'$4*+4)',)'#8Z@
C&5404*&('$L'cd',)('='*#'%&1,",*&'&,/+'1,4"=',)('V'*#'%&1'K&6L),0&'
."0'-,52&
<
_255':',)'&01*6'-,52&='2%4);'*+&'$#"('U)255U<
Object+data+
:'$+&)',11'+,%'8&&)'(&%4;)&('T'4015&0'2%4);'#D#'1,",(4;0
Serialisation/stringifying
:'1"#/&%%'#.'/#)-&"*4);'#8Z&/*'(,*,','.#"0,*'*+,*'/,)'8&'%*#"&('#"'
*",)%04**&('?/#00#)56','7*"4);@
e#"'M7='02%*'/#)-&"*'#8Z%'*#'7*"4);%'?#)56'(,*,'.#"0,*'M7'
,//&1*%@='$+4/+'02%*'&)/#(&'#8Z3%'(,*,'T'%*"2/*2"&'*#'8&'
"&*"4&-&('T'"&/#)%*4*2*&('5,*&"
<
Q;A'var studentAsJSON =
JSON.stringify(student)f
>)4I2&'K&6'.#"'&,/+'#8Z'
;&)&",*&('2%4);'U)208&"'$&55U'
%*#"&('4)'M7A
gA
],52&'%*#"&('+&"&'4%'"&*"4&-&('
."0'M7'8N'%&-&",5'*"4,5%',"&'
%*#"&(A
hA
Q,/+'*"4,5'*+&)'%*#"&('$L','K&6'
4)/52(4);',)'4)/"&0&)*&('-,52&'
#.'*+&')208&"A
iA
>1(,*&(')208&"'$"4**&)'8,/K'
*#'U)208&"'$&55U'4)'M7='
#-&"$"4*4);'1"&-'-,52&
NA
[&,(6'.#"')&9*'8,*/+'#.'*"4,5%'*#'
8&'%*#"&(
WA
J#015&94*6':'0,)6'5#;4/,5'1,*+%='+,"('*#'"&,%#)'8&+,-4#2"
Q,%6'*#'$"4*&'bad+software
<
M#$'8,""4&"'*#'&)*"6
<
j&)&",556',//&1*&('86'115
<
Failure
H&"%4%*&)/&
B01#"*,)*'8&/,2%&'$&'$,)*'*#'%,-&'(,*,'.#"'.2*2"&'2%&
<
PPinitialise from
PDO D0,K4);'#8Z&/*'."0'M7','
/5,%%'*+,*'+,%'0&*+#(%
%
M7V'/,)'#)56'%*#"&'%*"4);%
\7Y_V'%*"4);'(,*,'.#"0,*'*+,*'/,)'&91"&%%'#8Z%3'(,*,'T'%*"2/
:E',)'#8Z'/,)'8&'%*"4);4.4&('*#','\7Y_'%*"4);',)('%,-&('*#'M7='*+&)'
5,*&"'"&*"4&-&(',%','\7Y_'%*"4);',)('1,"%&('?"&,%%&085&(@'4)*#',)'
#8Z'4)'\7
Obj+in+JS++<--stringifying-->+JSOn+string+<--parsing/reassembling-->+
saved+to+LS
>)1"&(4/*,85&'8&+,-A<
!,('&91<
R11'/",%+&%<
C,*,'5#%%<
H15',.",4('*#'$#"K'$L'
%#.*$,"&'DDE'(4%*"2%*4);
<
PP&%1'4.'2%&('4)'%,.&*6L%&/2"4*6'
/#)*"#5'%6%*&0%'?&;A',2*#145#*@
<
Week$7:$Persistent$Data$Storage
72)(,6='k'R1"45'hlgm
gWVlk
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Browsers do not have free access to computer"s file system to store and retrieve docs. Sandboxed = isolated from the rest of the platform it"s running on for security. Important because we want to save data for future use. Cookies = data in the form of small text files confined to browser"s sandbox downloaded when user visits website, then stored locally by browser. Usually identifies user (small amnt of info) (eg. shopping cart id --> user id) Sent up as part of http request to website when website revisited. Limited to small amnt of text (max 4kb) Kept until deletion by user/expiration (deleted by browser on your behalf) --> poor solutions for web apps to store data. **can be used to track users" activities online w/o users" knowledge --> eu legislation required websites to disclose use of cookies and get users" agreement. Can be used, among other things, to identify browser to a web server.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents