|
home—lects—exams—hws
D2L—breeze (snow day)
From PHP Visual Quickstart Guide by Larry Ullman
Originally based on notes by Jack Davis (jcdavis@radford.edu)
We have looked at how php includes
Gotcha:session_start() puts a write-lock on the session file, so any other process trying to access it will block. (In particular: that 'other process' might be yourself, via an included-file which is also doing asession_start() !) One possible workaround (and good practice regardless): As soon as you're done updating any persistent values to$_SESSION , callsession_commit . This writes and closes the data file, although it doesn't unset data in memory so you can still refer to$_SESSION . (Just remember that any later changes made to the array are no longer being committed, and because you've given up the lock others might be updating the file w/o you seeing any changes. You can apparently callsession_commit again later, though presumably if some other process is accessing the file it may block and then it will overwrite the other file's changes.)
IMPORTANT:
If your session allows access to any secure information
(for instance, once a user successfully types a password,
you set
But we don't create that cookie ourselves!
We'd just called
php_ini('session.cookie_secure',true) |
IT-AUTH -- source-code not released to students, since it enables students to create popular RU pages that authenticate and surreptitiously log each user's password.
The solution is clever: Your page has a form that submits to https://php.radford.edu/~it-auth/vsp09/login.php. Your form passes in two strings (via hidden inputs, presumably):
Don't tempt an honest man.
To be effective, you'd better use a cookie-name that can't be guessed —
in particular, if I use your site and then check my own cookies,
hopefully I won't be able to look at that cookie name/value and
guess what somebody else's cookie name/value is!
https://php.radford.edu/~it-auth/vsp09/tutorial.php
home—lects—exams—hws
D2L—breeze (snow day)
©2012, Ian Barland, Radford University Last modified 2012.Oct.19 (Fri) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |