Mad Nightmare Posted October 25, 2009 Share Posted October 25, 2009 Hello, I'm new here So Hey Everybody! I'm also quite new to php, so I need some advice, if anybody is willing to give it. I'm trying to make a text based game in php, but i'm unsure as to how to make the login system. What I have right now, is something that, when you log in, you pass your username and password into the next page, the login page. So it checks that the username exists, and then that the hashed password is the same as the hashed password stored in the MySQL Database. Now, im not sure how to ensure that the player STAYS logged in. My plan is so that if the player is inactive for 5 minutes, they will be automatically logged out. My first instinct would be to use $_SESSION, but im not sure exactly how its used, and i was told by someone that it is ridiulous to use $_SESSION for a game and that i should use $_COOKIE. Can anybody give me a little advice on what to do, and if it is $_SESSION, could you explain how to register sessions and use them, not in high detail of course, that would take up too much of your time, but just a quick overview if possible. Thanks In Advance, Nightmare Quote Link to comment https://forums.phpfreaks.com/topic/178961-login/ Share on other sites More sharing options...
DEVILofDARKNESS Posted November 9, 2009 Share Posted November 9, 2009 some use $_SESSION, some use $_COOKIE (I use $_SESSION) session_start() //has to be the first line of your php code if you need sessions $_SESSION['example'] = 'this is an example'; // asigns the string to a session print $_SESSION['example']; // prints This is an example $example = $_SESSION['example']; //asigns the value of the session to a variable Quote Link to comment https://forums.phpfreaks.com/topic/178961-login/#findComment-954256 Share on other sites More sharing options...
mikesta707 Posted November 9, 2009 Share Posted November 9, 2009 If you are going to use cookies, be careful, because cookies are trivial to change. For a log in, I would suggest sessions, but for their login expiring, you could use a cookie (and obviously just refresh the cookie every time they go to a new page, or do something) Quote Link to comment https://forums.phpfreaks.com/topic/178961-login/#findComment-954258 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.