
Introduction to Sessions and Cookies

Quiz
•
Information Technology (IT)
•
University
•
Easy
Joseph Andreas
Used 6+ times
FREE Resource
17 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the primary purpose of using sessions in PHP?
To store data on the server for a specific user
To track user preferences across multiple visits
To store large amounts of data permanently
To ensure that all users share the same data
Answer explanation
Sessions store user-specific data on the server across multiple requests, ensuring continuity for a user during their visit
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a key difference between sessions and cookies?
Sessions store data on the client-side, whereas cookies store data on the server
Cookies expire after the browser is closed, while sessions persist indefinitely
Sessions are stored on the server, whereas cookies are stored on the client
Cookies cannot store user authentication details
Answer explanation
Sessions store data on the server and use a session ID to link the user, while cookies store data directly on the client’s browser
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What PHP function is used to start a session?
start_session()
session_begin()
session_start()
init_session()
Answer explanation
session_start() initializes a session and must be called before any output is sent to the browser
4.
MULTIPLE SELECT QUESTION
45 sec • 2 pts
Which of the following is TRUE about cookies?
They are stored in the client’s browser
They can store sensitive data securely
They can be accessed using $_COOKIE in PHP
They are deleted as soon as the user leaves the website
Answer explanation
Cookies are stored on the client’s browser and can be accessed in PHP using the $_COOKIE superglobal. However, they are not secure for storing sensitive data
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you set a cookie in PHP?
create_cookie('user', 'JohnDoe', time() + 3600);
setcookie('user', 'JohnDoe', time() + 3600, '/');
store_cookie('user', 'JohnDoe', time() + 3600);
cookie_set('user', 'JohnDoe', time() + 3600);
Answer explanation
setcookie() is the correct function to create a cookie, with parameters specifying the name, value, expiration time, and path
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you delete a cookie in PHP?
deletecookie('user');
setcookie('user', '', time() - 3600, '/');
remove_cookie('user');
unsetcookie('user');
Answer explanation
Setting the cookie’s expiration time to a past value removes it from the browser
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What function is used to destroy a session?
session_delete();
session_end();
session_unset(); session_destroy();
session_remove();
Answer explanation
session_unset() clears the session variables, and session_destroy() terminates the session
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
InfoSec Quiz 1

Quiz
•
University
20 questions
GDG ANDROID BOOTCAMP QUIZ

Quiz
•
University
20 questions
PCII DSS and GDPR

Quiz
•
University
15 questions
Q1. Human Computer Interaction

Quiz
•
University
19 questions
Windows File Sharing Quiz

Quiz
•
University
19 questions
Usability Heuristics Quiz

Quiz
•
University
16 questions
Keamanan Jaringan Komputer

Quiz
•
12th Grade - University
15 questions
Event Handling Quiz

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Information Technology (IT)
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

Interactive video
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University