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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.