Prev | Current Page 523 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

Its prototype
looks like this:
boolean session_start()
Executing session_start() will create a new session if no SID is found, or continue
a current session if an SID exists. You use the function simply by calling it like this:
session_start();
454 CHAPTER 18 ?–  SESSION HANDLERS
Note that the session_start() function reports a successful outcome regardless
of the result. Therefore, using any sort of exception handling in this case will prove
fruitless.
You can eliminate execution of this function altogether by enabling the configuration
directive session.auto_start. Keep in mind, however, that this will start or resume a
session for every PHP-enabled page.
Destroying a Session
Although you can configure PHP??™s session-handling directives to automatically destroy
a session based on an expiration time or probability, sometimes it??™s useful to manually
cancel out the session yourself. For example, you might want to enable the user to
manually log out of your site. When the user clicks the appropriate link, you can erase
the session variables from memory, and even completely wipe the session from storage,
done through the session_unset() and session_destroy() functions, respectively.
The session_unset() function erases all session variables stored in the current session,
effectively resetting the session to the state in which it was found upon creation (no
session variables registered).


Pages:
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535