// File name: session02.php
// http://webmonkey.wired.com/webmonkey/00/05/index2a.html
// if a session does not yet exist for this user, start one
session_start();
if (!$PHPSESSID) {
session_register('body_color');
session_register('text_color');
} else if ((!$body_color) || (!$text_color)) {
session_register('body_color');
session_register('text_color');
}
// do something w/ POST vars
$body_color = $sel_body_color;
$text_color = $sel_text_color;
?>
Setting Prefs
if (!$body_color) {
$body_color = "#FFFFFF";
}
if (!$text_color) {
$text_color = "#000000";
}
/* Then there's the cookie aspect: What if a user doesn't accept your PHPSESSID cookie?
/* How will PHP know which session file to use, if it can't extract a session ID from a
/* cookie? In this case, it then becomes your responsibility to send the value of
/* PHPSESSID via GET. For example,
/*
/* If you now feel your color selections are atrocious, please feel
/* free to change your preferences.
/*
/* As part of the link, add "?PHPSESSID=[value]":
/*
/* If you now feel your color selections are atrocious, please feel
/* free to change your preferences.
/*
/* It's a little more work for you, but it ensures that a session ID of some sort always
/* follows users as they move through your site. */
?>
" TEXT=" echo "$text_color"; ?>">
Your Preferences Have Been Set
As you can see, your BODY color is now echo "$body_color"; ?> and your TEXT color is now echo "$text_color"; ?>.
If you now feel your color selections are atrocious, please feel free to change your preferences.