
Introduction to Sessions and Cookies
Quiz
•
Information Technology (IT)
•
University
•
Practice Problem
•
Easy
Joseph Andreas
Used 6+ times
FREE Resource
Enhance your content in a minute
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
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?
Similar Resources on Wayground
15 questions
Q1. Human Computer Interaction
Quiz
•
University
12 questions
Recap W02 - W04 Information and Communication Technology
Quiz
•
University
20 questions
PTS Genap Informatika Kelas XI
Quiz
•
11th Grade - University
20 questions
PPL 223 (QUIZ 1) Introduction to Programming Languages
Quiz
•
University
13 questions
Nano quiz: Bottleneck of Motivation 2 and Receptivity Threshold
Quiz
•
University
15 questions
Event Handling Quiz
Quiz
•
University
20 questions
GDG ANDROID BOOTCAMP QUIZ
Quiz
•
University
19 questions
Windows File Sharing Quiz
Quiz
•
University
Popular Resources on Wayground
10 questions
Honoring the Significance of Veterans Day
Interactive video
•
6th - 10th Grade
9 questions
FOREST Community of Caring
Lesson
•
1st - 5th Grade
10 questions
Exploring Veterans Day: Facts and Celebrations for Kids
Interactive video
•
6th - 10th Grade
19 questions
Veterans Day
Quiz
•
5th Grade
14 questions
General Technology Use Quiz
Quiz
•
8th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
15 questions
Circuits, Light Energy, and Forces
Quiz
•
5th Grade
19 questions
Thanksgiving Trivia
Quiz
•
6th Grade
Discover more resources for Information Technology (IT)
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)
Quiz
•
8th Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
9 questions
Principles of the United States Constitution
Interactive video
•
University
18 questions
Realidades 2 2A reflexivos
Quiz
•
7th Grade - University
10 questions
Dichotomous Key
Quiz
•
KG - University
25 questions
Integer Operations
Quiz
•
KG - University
7 questions
What Is Narrative Writing?
Interactive video
•
4th Grade - University
20 questions
SER vs ESTAR
Quiz
•
7th Grade - University
