PHP2e_Chapter09_ReviewQuestions

True/False
Indicate whether the statement is true or false.

____	1.	Maintaining state refers to storing persistent data about a Web site visit using hidden form fields, query strings, cookies and sessions.

____	2.	A hidden form field is not displayed by the browser.

____	3.	Hidden input elements are visible in the URL when you use the get method but are not visible in the source code of the Web page.

____	4.	The $_REQUEST[] autoglobal is always good choice to use as it contains all of the array elements of the $_GET[], $_POST[], and $_COOKIE autoglobal arrays.

____	5.	You can use a query string to pass information from one Web page to another.

____	6.	You cannot append a query string to any URL on a Web page.

____	7.	You can access any query string data that is appended to a URL from PHP by using the $_POST autoglobal.

____	8.	Query strings permanently maintain state information.

____	9.	Hidden form fields maintain state information between Web pages, but not when the Web session closes.

____	10.	To make it possible to store state information beyond a current Web page session, Microsoft invented cookies.

____	11.	Cookies are stored in a binary file on the user’s computer.

____	12.	Persistent cookies remain available only for the current browser session.

____	13.	Cookies were originally created for use with CGI scripts.

____	14.	Each individual server or domain can store between 20 and 70 cookies on a user’s computer.

____	15.	The setcookie() function has no required arguments.

____	16.	You can call the setcookie() function at any location in your Web page.

____	17.	Users can choose whether to accept cookies that a script attempts to write to their system.

____	18.	Cookies created with the name and value arguments are temporary cookies.

____	19.	The setcookie() function can be called only once.

____	20.	Since cookies must be set individually, they cannot be stored in arrays.

____	21.	By default, cookies cannot contain semicolons.

____	22.	You can use special characters in cookies created in PHP.

____	23.	In URL encoded format, each space character is represented by %20.

____	24.	Encoding does not occur for standard alphanumeric characters.

____	25.	For a cookie to persist beyond the current browser session you must use the terminate argument with the setcookie() function.

____	26.	By default, a cookie is not available to all Web pages in the same directory.

____	27.	You use the path argument to share cookies across multiple servers in the same domain.

____	28.	You do not need to delete persistent cookies because they automatically cease to exist when the current browser session ends.

____	29.	The session_start() function does not accept any arguments.

____	30.	Session state information is stored in the $_SESSION autoglobal.

Multiple Choice
Identify the choice that best completes the statement or answers the question.

____	31.	 Which of the following is not a tool for maintaining state information with PHP?
a.	hidden form fields	c.	functions	
b.	query strings	d.	cookies	

____	32.	You can access the values submitted from the form by using the $_GET[] and ____ autoglobals.
a.	$_POST[]	c.	$_RETRIEVE[]	
b.	$_FIND[]	d.	$_SEND[]	

____	33.	One way to preserve information following a user’s visit to a Web page is to append a  ____ at the end of a URL.
a.	function	c.	auto-global	
b.	query string	d.	indentifier	

____	34.	To pass information from one page to another using a query string, you add a(n) ____ immediately after the URL, followed by the query string containing the information you want to preserve in name=value pairs.
a.	ampersand (&)	c.	question mark (?)	
b.	backslash (\)	d.	forward slash (/)	

____	35.	You separate individual name=value pairs within a query string using ____.
a.	ampersands (&)	c.	question marks (?)	
b.	backslashes (\)	d.	forward slashes (/)	

____	36.	How many name=value pairs are in the following URL?

<a href=”http://www.URL.com/TargetPage.php?firstName=Bill&lastName=Sciuto&occupation=teacher “>Link Text</a>

a.	one	c.	three	
b.	two	d.	four	

____	37.	Cookies can be temporary or ____.
a.	persistent	c.	invisible	
b.	relational	d.	hidden	

____	38.	Whenever a Web client visits a Web server, saved ____ for the requested Web page are sent from the client to the server.

a.	forms	c.	cookies	
b.	fields	d.	identifiers	

____	39.	Web browsers can limit the total number of cookies stored on a user’s computer to at least ____.
a.	200	c.	400	
b.	300	d.	500	

____	40.	You create a cookie by passing to the setcookie() function a required ____ argument and five optional arguments.
a.	name	c.	expires	
b.	value	d.	path	

____	41.	Omitting which of the following from the setcookie() function is equivalent creating a non-existent cookie?
a.	name	c.	expires	
b.	value	d.	path	

____	42.	PHP allows you to store cookie values in indexed or associative ____.
a.	functions	c.	arrays	
b.	text files	d.	scripts	

____	43.	What is the hexadecimal ASCII equivalent of a space character?
a.	19	c.	22	
b.	20	d.	25	

____	44.	Which of the following characters would encoding not encode?
a.	,	c.	%	
b.	/	d.	^	

____	45.	For a cookie to persist beyond the current browser session, you must use the ____ argument with the setcookie() function.
a.	secure	c.	path	
b.	expires	d.	domain	

____	46.	To set the expire date of a persistent cookie, use PHP’s ____ function and add to it an integer in seconds to specify when the cookie should be deleted.
a.	date()	c.	time()	
b.	expire()	d.	day()	

____	47.	The ____ argument determines the availability of a cookie to other Web pages on a server.
a.	secure	c.	path	
b.	expires	d.	domain	

____	48.	The ____ argument is used for sharing cookies across multiple servers in the same domain.
a.	secure	c.	expires	
b.	domain	d.	path	

____	49.	The ____ argument indicates that a cookie can only be transmitted across a secure Internet connection using HTTPS or another security protocol.
a.	secure	c.	domain	
b.	expires	d.	path	

____	50.	Cookies that are available to the current Web page are automatically assigned to the ____ autoglobal.
a.	$_GET	c.	$_COOKIE	
b.	$_POST	d.	$_FIND	

____	51.	If you want to store state information that will be available when a client revisits your Web site in the future, you must use ____.
a.	sessions	c.	autoglobals	
b.	cookies	d.	hidden form fields	

____	52.	Whenever you need to work with sessions in a PHP script, you must call the ____ function.
a.	set_cookie()	c.	keyword()	
b.	session_start()	d.	session_stop()	

____	53.	____ are random alphanumeric strings that identifies a session.
a.	Cookies	c.	Session IDs	
b.	Functions	d.	Hidden form fields	

____	54.	You store session state information in the $_SESSION ____.
a.	script	c.	autoglobal	
b.	function	d.	cookie	

____	55.	Session state information is stored in the ____ autoglobal.
a.	$_GET[]	c.	$_SESSION[]	
b.	$_POST[]	d.	$_COOKIE[]	

PHP2e_Chapter09_ReviewQuestions
Answer Section

TRUE/FALSE

	1.	REF:	497

	2.	REF:	506

	3.	REF:	506

	4.	REF:	509

	5.	REF:	515

	6.	REF:	515

	7.	REF:	515

	8.	REF:	517

	9.	REF:	517 | 518

	10.	REF:	518

	11.	REF:	518

	12.	REF:	518

	13.	REF:	518

	14.	REF:	518

	15.	REF:	518

	16.	REF:	519

	17.	REF:	519

	18.	REF:	519

	19.	REF:	519

	20.	REF:	519

	21.	REF:	520

	22.	REF:	520

	23.	REF:	520

	24.	REF:	520

	25.	REF:	521

	26.	REF:	525

	27.	REF:	525

	28.	REF:	529

	29.	REF:	531

	30.	REF:	532

MULTIPLE CHOICE

	31.	REF:	498

	32.	REF:	506

	33.	REF:	515

	34.	REF:	515

	35.	REF:	515

	36.	REF:	515

	37.	REF:	518

	38.	REF:	518

	39.	REF:	518

	40.	REF:	518

	41.	REF:	519

	42.	REF:	519

	43.	REF:	520

	44.	REF:	520

	45.	REF:	521

	46.	REF:	521

	47.	REF:	525

	48.	REF:	525

	49.	REF:	526

	50.	REF:	526

	51.	REF:	530

	52.	REF:	531

	53.	REF:	531

	54.	REF:	532

	55.	REF:	532