In addition to the server behaviors described above, two other sets of behaviors come
in handy on dynamic web pages.
Power Users' Clinic: Adding and Deleting Session Variables Using PHP Pages
Dreamweaver doesn’t provide a simple wizard to add the code necessary to create and
delete session variables with PHP pages, it isn’t difficult to add it yourself.
(Dreamweaver does, however, make quick work of retrieving session
variables; see Session Variables.)
The procedure is much like the one you use to add cookies (see the box on Adding and Deleting Cookies Using PHP)—for example, here, too, the script
runs when a visitor requests the page. When someone registers at your site, therefore,
you can store the email addresses they enter in the registration form as a session
To add a session variable, you must do two things. First, in Code view (Code View), add this code (on a single line) near the top of the
<?php if (!isset($_SESSION)) session_
This alerts PHP that you want to use session variables on this page (if you omit
this line, you can’t set or read session variables). Just as when you set a cookie, you
can’t have any HTML or even empty space before this line or you get a “Headers already
sent” error. Next, you set the session variable.