One method to add an extra layer of security during user authentication is called two-factor ________.
- Authentication
- Authorization Code
- Verification
- Authentication
To enhance security during user authentication, implementing "two-factor Authentication" is a recommended practice. This involves using two different methods to verify a user's identity.
The method of ensuring that data conforms to specific rules or definitions is called ________.
- Validation
- Sanitization
- Normalization
- Serialization
The process of ensuring data conforms to specific rules or definitions is called validation, which is essential for data integrity and security.
Imagine you are building an e-commerce application. When a user places an order, multiple operations like updating stock, logging order details, and processing payments are involved. Why would using transactions be beneficial in this scenario?
- To ensure data consistency
- To reduce database size
- To speed up data retrieval
- To simplify application code
Using transactions ensures that all the operations are treated as a single unit. If any part of the transaction fails, the entire transaction is rolled back, maintaining data consistency.
Which of the following headers can help in mitigating CSRF attacks?
- Content-Type
- X-Content-Security-Policy
- Referer-Policy
- X-Requested-With
The Referer-Policy header can help mitigate Cross-Site Request Forgery (CSRF) attacks by controlling which origins are allowed to make requests to the resource.
The path for which the cookie is valid can be set using the ________ parameter in the setcookie() function.
- cookie.max_age
- cookie.secure
- cookie.expires
- cookie.path
The 'cookie.path' parameter in the setcookie() function defines the path for which the cookie is valid, allowing for precise control over cookie scope.
In PHP, which exception is thrown if there's an error during JSON encoding?
- JsonException
- ParseException
- EncodingException
- JsonEncodeError
In PHP, if there's an error during JSON encoding, a JsonException is thrown. This exception provides information about the JSON encoding error, such as invalid data or an encoding issue. It's important to catch this exception to handle JSON encoding errors gracefully.
Which PHP configuration directive determines where session files are stored on the server?
- session.save_path
- session.cookie_lifetime
- session.gc_probability
- session.use_strict_mode
The 'session.save_path' directive in PHP determines the directory where session files are stored on the server. Understanding this directive is important for session management.
How can you prevent session fixation attacks in PHP?
- Regenerate session ID after login
- Use HTTPS to encrypt session data
- Use secure cookies
- Implement strong password policies
To prevent session fixation attacks, it's crucial to regenerate the session ID after a successful login to ensure the attacker can't predict the ID in advance. This improves security.
In PDO, named placeholders in prepared statements start with the symbol ________.
- :param
- $param
- ?param
- @param
In PDO, named placeholders in prepared statements start with a colon (:), so they are typically written as :param.
In PHP, the ________ function is used to get the length of a string.
- strlen()
- count()
- sizeof()
- strlength()
In PHP, the strlen() function is used to determine the length (number of characters) of a string. It's particularly useful for validating input or working with text data.