W4. Asynch & State - Cookies and local storage Flashcards

1
Q

What are cookies used for?

A
  • cookies provide a small amount of client-side storage
  • keep preferences
  • config info
  • returning visitors
  • info to re-use later in application
    (Cookies and local storage add state)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does cookie storage look like?

A

Cookie strings have key-value pairs

name1=value1;name2=value2;name3=value3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give some examples of pre-defined cookie fields

A
  • path
  • domain
  • max-age
  • expires
  • secure
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is LocalStorage for HTML5?

A

Alternative API for HTML5 for managing cookies, adds better support for local state
SessionStorage - managing a connected session, rather than a specific domain
Cleaner API for manipulating key-value pairs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Give examples of some methods in the LocalStorage API

A
  • clear() cookie for that page
  • getItem(key) key for which a value has been set
  • setItem(key, value) set key, value pair
  • removeItem(key) remove key, value pair for key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a session?

A
  • single use of a page
  • application level session extending beyond lifetime of a single transport level connection
  • long-lived application level interaction for a user
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What possible privacy considerations are there when using Cookies and LocalStorage?

A
  • both are used to track users: info between sites, sites visited, info input from session
  • cookies are all plain text
  • any server can set a cookie in an HTTP response (pages with 3rd party content)
  • GDPR: opt-in policy for use of tracking cookies
How well did you know this?
1
Not at all
2
3
4
5
Perfectly