[thelist] php sessions

Michele Wandrei michele at inthree.com
Tue Oct 15 13:31:02 CDT 2002

> /* start the session (no values registered yet, just the thing
itself) */
> session_start();

Sven, I wish I had read your post a few weeks ago when I was
struggling with this.  Good info.  The only thing I would add is
that session_start(); should be included at the start of every

Here's a tip that I learned the hard way.  While this is probably
obvious, and may give a seasoned programmer a good laugh, I will
admit to learning it the hard way.

<tip type="php sessions">

Make sure that you give your session variables names that are
different from the variables you use within the page!  I created
a user login system, registering person_id as a session variable
to track my user across scripts.  Well, one of the pages that
users can access is a directory listing of other names that
includes person_id.  When the registered user visited this page,
the value of the session variable person_id was replaced with the
last value of person_id that appeared on that page.  It's one of
those "duh" lessons that I won't forget!
Michele Wandrei
inThree Design

More information about the thelist mailing list