Introduction to Sessions and Cookies

Introduction to Sessions and Cookies

University

17 Qs

quiz-placeholder

Similar activities

İstifadəçi interfeysi

İstifadəçi interfeysi

University

15 Qs

KUIS HTML

KUIS HTML

11th Grade - University

20 Qs

ICC_QUIZ3_MODULE_7

ICC_QUIZ3_MODULE_7

University

20 Qs

Quiz 1 | Information Security | Kali Linux Commands

Quiz 1 | Information Security | Kali Linux Commands

University

20 Qs

HCI GOMS quiz

HCI GOMS quiz

University

15 Qs

CLC Unit 2 Lesson 1,2,3 and 4 Quiz

CLC Unit 2 Lesson 1,2,3 and 4 Quiz

University

12 Qs

INFORMATIKA KELAS 7A DAN TB

INFORMATIKA KELAS 7A DAN TB

7th Grade - University

15 Qs

CHAPTER 3: SYSTEM ANALYSIS AND DESIGN

CHAPTER 3: SYSTEM ANALYSIS AND DESIGN

University

19 Qs

Introduction to Sessions and Cookies

Introduction to Sessions and Cookies

Assessment

Quiz

Information Technology (IT)

University

Practice Problem

Easy

Created by

Joseph Andreas

Used 6+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?