PHP - Sessions Flashcards

1
Q

HTTP is a ______ _______; a communication protocol in which each new request cannot be linked to any previous requests.

A

HTTP is a Stateless Protocol; a communication protocol in which each new request cannot be linked to any previous requests.

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

But a client’s “session” with the server usually contains multiple HTTP requests. (e.g. ______)

A

But a client’s “session” with the server usually contains multiple HTTP requests. E.g. Shopping on Amazon, Browsing SLATE, etc.

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

The server can’t tell just by looking at the requests which ones go together. So, even if the same client requested different resources, the server wouldn’t know that they came from the ____ ____.

A

The server can’t tell just by looking at the requests which ones go together. So, even if the same client requested different resources, the server wouldn’t know that they came from the same client.

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

PHP Sessions address this issue, thereby allowing us to persist information across multiple requests.

If SLATE did not use sessions, a user would need to log in _____ _____ he/she requests a page.

A

PHP Sessions address this issue, thereby allowing us to persist information across multiple requests.

If SLATE did not use sessions, a user would need to log in every time he/she requests a page.

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

The server creates a ____ ______ when a session is started.

A

The server creates a unique identifier when a session is started.

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

The server stores this ______. This identifier will now _______ any session variables.

A

The server stores this identifier. This identifier will now reference any session variables.

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

The server sends that _______ to the client.

A

The server send that identifier to the client.

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

The client stores this identifier in a _______ (a form of storage on the client) and then provides the identifier with ________ requests.

A

The client stores this identifier in a cookie (a form of storage on the client) and then provides the identifier with subsequent requests.

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

When needed, the server would use the identifier (now sent with every request) and look for associated _______ data on the server.

A

When needed, the server would use the identifier (now sent with every request) and look for associated session data on the server.

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

The server script can now use the session variables found.

A

The server script can now use the session variables found.

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

How do I use it? (sessions)

A

1) Start the session
2) uses the $_SESSION associative array to read or write variables
3) That’s it! Remember to always start the session at the top of the page.
4) When you no longer need the session, use session_destroy()
5) The example below shows how we can retrieve a session variable across multiple requests.

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

page1.html

A

Name:

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

page2.php

A

<a>page3</a>

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

page3.php

A

<a>logout</a>

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

logout.php (destroying sessions)

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

When developing code that uses sessions, use a brand _____ ______ _____ or _____ all browser windows and clear all browser cookies/sessions so that you can be sure that the browser will not remember you after you close the development tab.

A

When developing code that uses sessions, use a brand new incognito tab or restart all browser windows and clear all browser cookies/sessions so that you can be sure that the browser will not remember you after you close the development tab.

17
Q

The sessions we have been using so far stores a session identifier in a ______. When a request is made, the identifier is sent to the server, then the server looks for the session data stored on the server side, based on that identifier.

A

The sessions we have been using so far stores a session identifier in a cookie. When a request is made, the identifier is sent to the server, then the server looks for the session data stored on the server side, based on that identifier.

18
Q

Recently, some developers prefer to store the data on the ___ ____ and pass all the user data with every _____.

A

Recently, some developers prefer to store the data on the client side and pass all the user data with every request.

19
Q

There is some conflict regarding ____ for authorization.

A

There is some conflict regarding JWT for authorization.