death_relic0 Posted June 5, 2012 Share Posted June 5, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/263710-alternative-to-session-for-keeping-user-logged-in/ Share on other sites More sharing options...
scootstah Posted June 5, 2012 Share Posted June 5, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/263710-alternative-to-session-for-keeping-user-logged-in/#findComment-1351448 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.