November 11, 201214 yr Hello, I'm working on this website, with some videos, and i would like to have a login system, to give my visitors the ability to rate and comment the videos. I'm not very familiar with login systems, and that's why i'm trying my luck here. My big problem is remembering if the user is logged in or not. I've created a simple login, with a form and when you press login, it will run a php script and connect to a database and check if the username is correct. If it is then it will redirect to a login page, and else it will redirect to wronglogin. As i said then i dont think the problem is the login part, but if i login to the website, and then lets say i click on a link in the menu, then i would have to login again? How can i check if the user has logged in, even when i go to other pages on the website? I've searched the internet, and some say i have to use cookies, with the entered password and username, and then check on every page if the cookie password and username is == to the username and password in the database? This might work, but i dont believe this is the best way of doing it? Another solution i found was using php sessions, but i dont know anything about php sessions or cookies, so if the best solution is one of these too, then i would love to know which is better and maybe get some help! Maybe if none of them, then i ofcause would love some help anyways!! -Tobias
November 11, 201214 yr Hello, I'm working on this website, with some videos, and i would like to have a login system, to give my visitors the ability to rate and comment the videos. I'm not very familiar with login systems, and that's why i'm trying my luck here. My big problem is remembering if the user is logged in or not. I've created a simple login, with a form and when you press login, it will run a php script and connect to a database and check if the username is correct. If it is then it will redirect to a login page, and else it will redirect to wronglogin. As i said then i dont think the problem is the login part, but if i login to the website, and then lets say i click on a link in the menu, then i would have to login again? How can i check if the user has logged in, even when i go to other pages on the website? I've searched the internet, and some say i have to use cookies, with the entered password and username, and then check on every page if the cookie password and username is == to the username and password in the database? This might work, but i dont believe this is the best way of doing it? Another solution i found was using php sessions, but i dont know anything about php sessions or cookies, so if the best solution is one of these too, then i would love to know which is better and maybe get some help! Maybe if none of them, then i ofcause would love some help anyways!! -Tobias You need to take a look at sessions and cookies in php
November 12, 201214 yr if the best solution is one of these too, then i would love to know which is better Generally, cookies are easier to program, can last longer and require less work of the server; sessions are more secure and allow you to store more data so your requirements will determine whether you use sessions or cookies but you will have to use one of them.
Create an account or sign in to comment