[ Team LiB ] Previous Section Next Section

Workshop

Quiz

1:

Which function would you use to start or resume a session?

2:

Which function contains the current session's ID?

3:

How can you associate a variable with a session?

4:

How would you end a session and erase all traces of it for future visits?

5:

How would you destroy session variables both within the current script and the session?

6:

What does the SID constant return?


Answers

A1:

You can start a session with the session_start() function.

A2:

You can access the session's ID with the session_id() function.

A3:

You set an element in the superglobal $_SESSION array.

A4:

The session_destroy() function removes all traces of a session for future requests.

A5:

You can unset session elements by unsetting all elements of the $_SESSION array, like so:

$_SESSION = array();

A6:

If cookies are not available, the SID constant contains a name/value pair that can be incorporated in a query string. This will pass the session ID from script request to script request.


    [ Team LiB ] Previous Section Next Section