p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: sessions and cookies


Message #1 on Fri, 17 May 2002 21:56:08
Hi,



I am desiging user-pages for users to update (php+mysql).

Everything worked fine so far, but when I implemeneted
function for users to change thier password, as soon they
submit data to db (insert), they are logget out of the
pages.

I register password and username in my session.

Ofcourse, session is not using the same password any more.

Is there a way to register information on client side with
cookies, so users are able to stay in the system after
changing password without logging out and loggin in again.

Are cookies good way to solve this problem?
Example would help.


Message #2 on Fri, 17 May 2002 14:47:54 -0700
> I register password and username in my session.
>
> Ofcourse, session is not using the same password any more.
>
> Is there a way to register information on client side with
> cookies, so users are able to stay in the system after
> changing password without logging out and loggin in again.


Don't session register the password.  Test the password when they log in,
and register their user id and/or create a "logged in" variable and register
that instead.  That way, a user can modify whatever profile information they
want and not worry that the items they change will have any effect on their
session.

If you'd like example code of sessions, I'd recommend going to
www.hotscripts.com, www.phpbuilder.com, or some other PHP code repository
site and look at session/authentication/permissions code packages.

Or you can download some PHP content management systems like PHPNuke or
Thatware and look at their code to see how they do it.

Lastly, there are sites which post articles and columns about php
development, and you can probably find some simple tutorials or howto's
there.  www.phpbuilder.com and www.devshed.com are two such sites.


Take care

  Return to Index