w3d4 Flashcards

1
Q

What does it mean that HTTP is a stateless protocol?

A

All requests are independent of one another; no information is saved between requests.

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

What is an advantage of a stateless protocol?

A

It allows for server speed optimizations.

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

What is a cookie?

A

A piece of data stored in a web browser that is sent along with HTTP requests to help the server identify information about the sender; solves the problem of statelessness.

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

How does a server check that a cookie is valid?

A

When the cookie is initially set, the server stores token in its database, and it compares the sent cookie to the stored cookie token.

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

What is a permanent cookie?

A

A cookie with an expiration date very far in the future, which causes it to persist for a long time.

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

What is a session cookie?

A

A cookie without an expiration date, which will be deleted when the browser closes.

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

How can cookies be used, for example, to allow a non-logged in user to store items in their cart?

A

By giving the anonymous user a session cookie.

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

What is an advantage of keeping cookie sizes under 4kB?

A

If a cookie needs to be sent multiple times, then keeping the size small will speed up internet use.

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

T/F: Important information which persists can be stored in cookies.

A

F; Users clear cookies all the time so you shouldn’t count on its presence.

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

What is a session?

A

Data about a particular HTTP transaction which is reused for future contexts. Cookies are an implementation of sessions.

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

What does the sessions hash contain?

A

Data about previous sessions.

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

How do we remove something from the sessions hash?

A

Set it to nil

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

What is the flash hash?

A

A hash of values that is available during the next request, but is cleared with each new request.

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

What do we do if we want to display the flash hash in the same request?

A

Use flash.now

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

What is a CSRF attack?

A

A cross site request forgery, in which a deceptive form on one site sends data to another site.

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

What is an authenticity token?

A

A token for a user that is uploaded/set with each new request.