Cookies & Sessions Flashcards

1
Q

Is HTTP stateless?

A

yes, meaning websites cannot keep the state of a visit across different HTTP requests

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

What makes HTTP stateful?

A

Cookies, invented by Netscape in 1994

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

Cookies

A

textual info installed by a website into the “cookie jar” of a web browser

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

Cookie Jar

A

storage space where a web browser stores cookies

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

Cookie attributes

A
actual content
expiration date
path
domain
optional flags: http only, secure
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Set-Cookie

A

http header where a server can set a cookie

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

Where are cookies sent

A

only to valid domain/path when the are not expired and according to their flags

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

What fields set the scope of the cookie?

A

The domain and path field.

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

What happens when a web server installs a cookie?

A

The web server sets the domain field to the website. Then the browser will use the cookie for every request sent to that domain and subdomains

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

What happens to the cookie if the server does not specify the domain attribute?

A

The browser will auto set the domain as the server domain and set the cookie host-only flag = the cookie will be sent only to that precise hostname.

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

Http-Only Cookie Attribute

A
  • client sets http-only flag for cookie
  • prevents JS, Flash, Java and other non-HTML from reading the cookie
  • this prevents XSS cookie stealing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Secure flag (cookie attribute)

A

creates secure cookies sent ONLY over https

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

Can a cookie have more than one value?

A

Yes, a server can set more than one value with KEY=Value pairs

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

When are cookies often installed?

A

at login

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

how does a login cookie work?

A
  • browser send POST request
  • server responds with Set-cookie header field telling browser to install cookie
  • browser considers header fields for each subsequent request to server
  • if checks pass, browser inserts cookie header in request
How well did you know this?
1
Not at all
2
3
4
5
Perfectly