NYCPHP Meetup

NYPHP.org

[nycphp-talk] $_SESSION, Logout, and Shared Host

Christopher R. Merlo cmerlo at ncc.edu
Wed Nov 4 22:07:56 EST 2009


On Wed, Nov 4, 2009 at 9:49 PM, Tim Lieberman <tim_lists at o2group.com> wrote:

True.  You've just learned a valuable lesson: You should only ever call
> session_start() in one place.


It's funny; that just occurred to me as I was about to read your response.
"Why on earth," I started saying to myself, "would I have called this from
multiple places?"  Sure enough, my login.php script does exactly that.  What
I should really be doing is starting the session in one place (I call it
_header.inc), which I already include from every other script -- except a
couple of really old ones, like login.php, which I was too lazy to rewrite
when I re-engineered this project with PHP 5 compliance, jQuery, etc.

So, pilot error.  :)


> I suggest you do *both*.  If you're repeating configuration stuff
> (session_start()) all over the place, you should be refactoring anyway.
>
> Doing some fake namespacing in $_SESSION is a good idea, too.
>
> I'd do both, but I'd refactor all of your configuration/bootstrapping
> first.
>

That's exactly what I'm going to do.  I also started thinking about when I
roll this software out for other faculty to use; each instance should be
creating its own session variables.

Anyway, thanks Tim and list for helping me find my mistake.
-c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20091104/8f0873b9/attachment.html>


More information about the talk mailing list