Jump to content

alternative to session for keeping user logged in?


death_relic0

Recommended Posts

hey guys..

im learning php atm, and decided to become a member of this site since i will probably be doing  a decent amount of php in the future inshAllah, and when ur active in something, its always helpful to be an active member in a forum related to that "something"...

 

 

anyways, im doing a practice project in php (making a forum), and trying do decide on a mechanism to keep a user logged in. ive created a user class, through which a user is authenticated (on sign in) and all future user account related operations will be through that class (i.e user related info retrival, when a user makes a post/comment, etc)

 

to keep a user logged in, the easiest path seemed to be to use session and store the user object in a session (not cookies since that would be a security risk), but after doing some reaserch i found out that sessions can but a huge load on a system, specially if large amounts of data is saved in them.

 

im thinking a second alternative would be to save only the user id, but that would mean on each page i will have to rebuild the user object, which i guess would again put a significant load on the server.

 

what is the best method to use, whether it be an alternative to using session altogether, or an alternative implementation?

 

thanks in advance

A single database query to fetch the user with the saved user ID shouldn't be a big deal.

 

If you don't want to do that on every page load you could look into caching with something like memcached or APC, but I don't think that is really necessary.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.