|| QUESTIONS & ANSWERS || RATED A+
Description: This CIST2351 PHP Programming I (Chapter
11) file includes top-rated A+ questions and verified
answers for the latest 2025 version. Covers PHP scripting,
arrays, forms, and web functionality. Ideal for students
mastering PHP development fundamentals.
Keywords: CIST2351 PHP programming chapter 11 web
development PHP arrays forms and functions server
scripting coding exam web programming IT course
material
Section 1: Cookies
1. What is a cookie in the context of PHP?
A. A small text file stored on the web server
B. A session variable
C. A small text file stored on the client's computer
D. An encrypted PHP script
2. Which PHP function is used to send a cookie to the client's browser?
A. set_cookie()
B. create_cookie()
C. send_cookie()
D. setcookie()
,3. The setcookie() function must be called...
A. After any output is sent to the browser
B. Before any output is sent to the browser
C. Inside the HTML <head> section
D. It can be called anywhere
4. What is the third parameter of the setcookie() function used for?
A. The cookie's value
B. The cookie's name
C. The cookie's expiration time
D. The path on the server
5. To create a cookie that expires when the user closes their browser, what should the
expiration parameter be set to?
A. 0
B. -1
C. time() + 3600
D. null
6. How do you access a cookie's value from a subsequent page request?
A. $_REQUEST['cookie_name']
B. $_GET['cookie_name']
C. $_POST['cookie_name']
D. $_COOKIE['cookie_name']
7. To delete a cookie, you should...
A. Use the deletecookie() function
B. Set the cookie's value to an empty string
C. Set the cookie's expiration time to a point in the past
D. Use the unset() function on the $_COOKIE array
8. Which of the following is a potential security concern with cookies?
A. They can contain viruses
B. They are stored on the server
C. They can be viewed and modified by the user
D. They consume significant server memory
Section 2: Sessions
, 9. Where is session data stored by default in PHP?
A. In a database on the server
B. In a cookie on the client's machine
C. In temporary files on the server
D. In the browser's local storage
10. Which function must always be called before you can register session variables?
A. start_session()
B. session_start()
C. init_session()
D. session_register()
11. How do you store a value in a session variable?
A. $_SESSION['var_name'] = $value;
B. session_register('var_name', $value);
C. $var_name = session_value($value);
D. set_session('var_name', $value);
12. What is the purpose of the session ID?
A. To encrypt the session data
B. To uniquely identify a user's session on the server
C. To name the session file on the client's computer
D. To set the session's expiration time
13. How is the session ID typically passed between pages?
A. Through the $_GET array
B. Through a cookie or a URL parameter
C. Through the $_POST array
D. Through a hidden form field
14. Which function destroys all data registered to a session?
A. session_destroy()
B. session_end()
C. unset_session()
D. session_unset()
15. To remove a specific variable from the current session, you would use:
A. unset($_SESSION['var_name']);
B. session_unset($_SESSION['var_name']);