Midterm Study 3 Flashcards

1
Q

Is HTTP a stateful or or stateless protocol?

A

HTTP is a stateless protocol, meaning there is no built-in mechanism for linking one HTTP request with another.

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

What is session management?

A

Any web app that remembers who the user is and/or what they were doing from one HTTP request to the next is using some form of session management

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

What gets sent to the client along with the HTTP response in order to implement session management?

A

A cookie (token) usually valid until the browser is closed.

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

How is the cookie used?

A

The cookie contains a unique id to identify the user. When the user initiates a new HTTP request, the browser sends the cookie back along with it. When the server receives a request with a session cookie, it can look up the id to retrieve information about the session

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

How do you start a session and where does it go?

A

session_start();
Starts or resumes a session. Must be called before any output has been written into the HTTP Response (i.e. above the line in a PHP web page).

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

How is session information stored?

A

$_SESSION[]
An associative array to store and retrieve data for the current session. You can store values of any type in this array, including other Array values. Values that come from user-defined parameters should be validated and/or filtered before they are stored

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

How do you remove all values from a session?

A

session_unset()

Removes all values from $_SESSION.

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

How do you end a session?

A

session_destroy();
Terminates the session. The next call to session_start() will start a new session with an empty $_SESSION[]object. Note that you must call session_start() to resume the session before you can destroy it.

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

What is the number one way websites and databases get hacked in the real world?

A

SQL Injections

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

What does PDO stand for?

A

PHP Data Objects

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

What is a SQL injection?

A

An injection attack is a malicious hack that can occur any time user input is executed as code

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

What is the number 1 way to prevent SQL injections?

A

Prepared statements

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

What does the syntax for a prepared statement look like?

A

$id = filter_input(INPUT_POST, “id”, FILTER_SANITIZE_SPECIAL_CHARS); $command=”DELETE FROM polls WHERE ID=?”;
$stmt = $dbh->prepare($command);
$userParams = [$deleteid];
$stmt->execute($userParams);

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

What does a SELECT statement look like in SQL

A

SELECT * FROM “mytable” WHERE “quantity” = 0

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

What does an INSERT statement look like in SQL?

A

INSERT INTO “mytable” (col1, col2) VALUES (22, ‘String’)

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

What does a DELETE statement look like in SQL?

A

DELETE FROM sales WHERE transaction_id = 5

17
Q

What does an UPDATE statement look like in SQL?

A

UPDATE departments SET manager_first_name = ‘Bob’ WHERE department_id = 5