Jump to content

Specific User Sessions/Cookies Using PHP/SQL


Usarjjaco

Recommended Posts

Hello Everyone,I feel a little silly that my first post on here is one requesting help instead of contributing; but alas, here I am :). I'll get right to the dirty of things:My Intent: Being able to log in users who have created an account; and have them see information specific to that user (I'm designing a text based management game). My Understanding Thus Far: I know that in order to store information for a user I need to use sessions and/or cookies. I know that I can pull whatever data I want from my DB as long as I have the parameters from which to pull (Like a unique but unchanging user ID). From what I gather a cookie would be the way to go once I get multiple users as it keeps the load off of my server... advice on this would be appreciated too. I know that I need t ohave each user who logs in have a session/cookie that lets their access be pulled from the DB.My Problem: A) I know how to create a session; but from what I gather sessions all create a unique ID; and the problem with this is I need a specific and consistent USER based id that I can use to pull the same unique data from the DB on a user to user basis. :) Everything I have read on creating a cookie asks that I specify a "identifier" for the cookie (What will be displayed in the front end to the user) ... I am hoping that there is a way to have my DB automatically tell the cookie which user it is?C) Really this problem will be solved if I can get answers to A & B; but again I'm just looking to be able to have user "John Doe" be able to log in on day X , Y, Or Z ; and be able to have the DB pull his specific information while he is logged in.I'm sorry if this has been answered somewhere; I've searched but haven't found anything on it; so even someone pointing me to the right guide/thread would be appreciated. Thanks in advance for your time and understanding. I am learning the coding on my own so it's no easy process as I'm sure all of you know but I'm trying :)Kind Regards,JJ

Link to comment
Share on other sites

The session ID isn't related to the data you store in it. You don't need to handle the session ID, you can just store the user ID from the database in the session and access that on each page. It doesn't matter to your pages what the session ID is.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...