Skip to content

Latest commit

 

History

History
74 lines (64 loc) · 3.81 KB

n6aa.md

File metadata and controls

74 lines (64 loc) · 3.81 KB

Stars Badge Forks Badge Pull Requests Badge Issues Badge GitHub contributors Visitors

Don't forget to hit the ⭐ if you like this repo.

PHP: Form & Session & Cookies

Set A

  1. a) $_GET
  2. b) session_start()
  3. c) setcookie()
  4. a) $_SESSION
  5. a) session_destroy()
  6. d) isset($_COOKIE['cookie_name'])
  7. a) $_COOKIE['cookie_name']
  8. a) unset($_SESSION['variable_name'])
  9. b) By specifying the expiration time in the setcookie() function
  10. a) isset($_SESSION['variable_name'])
  11. c) filter_input()
  12. a) count($_SESSION['array_variable'])
  13. b) header('Location: new_page.php')
  14. b) session_id()
  15. b) htmlspecialchars()
  16. a) $_GET['parameter_name']
  17. c) $_SERVER['REMOTE_ADDR']
  18. a) $_SESSION['array_variable'] = array(...)
  19. a) By using the preventDefault() function in JavaScript and validating the form on the server-side using PHP
  20. a) isset($_COOKIE['cookie_name'])
  21. a) By echoing a success message in the PHP script that processes the form
  22. a) setcookie('cookie_name', '', time() - 3600);
  23. c) if (empty($_POST['field_name']))
  24. a) $_SESSION['variable_name']
  25. b) By using the htmlspecialchars() function to encode special characters in the input
  26. a) if (session_status() === PHP_SESSION_ACTIVE)
  27. a) By setting the session_lifetime configuration directive in the php.ini file
  28. a) $_POST['input_field_name']
  29. a) $_SESSION['variable_name'] = value;
  30. a) echo session_id();
  31. a) By disabling the submit button after the form is submitted
  32. a) $_COOKIE['cookie_name']
  33. a) setcookie('cookie_name', 'value', time() + 3600);
  34. a) isset($_SESSION['variable_name'])
  35. a) By using prepared statements and parameterized queries when interacting with a database
  36. a) session_unset()
  37. a) By serializing the array and storing it in a single cookie value
  38. a) $_POST['input_field_name']
  39. a) $_SESSION['variable_name']
  40. a) By setting each cookie to an empty value using the setcookie() function
  41. a) $_SESSION['variable_name'] = value;
  42. a) isset($_COOKIE['cookie_name'])
  43. a) $_GET['variable_name']
  44. a) setcookie('cookie_name', '', time() - 3600);
  45. a) if ($_POST['field_name'] === '')
  46. a) session_id()
  47. a) setcookie('cookie_name', 'value', time() + 3600, '/', '', false, true);
  48. a) $_SERVER['HTTP_USER_AGENT']
  49. a) By storing the preferences in a JSON-encoded string and setting it as a cookie value
  50. a) count($_SESSION['array_variable'])

Contribution 🛠️

Please create an Issue for any improvements, suggestions or errors in the content.

You can also contact me using Linkedin for any other queries or feedback.

Visitors