August 13, 201016 yr Hello, Its me again! Now cookies are nice to have around specialy when it comes to the trusty "Remember Me" feature on login forms, Im currently storing the USER_ID inside a cookie, And then, further on in the script fetching details from the database about the user using the USER_ID stored inside the cookie. Ive tried changing the user ID inside the cookie to try and fool the script into thinking it was another user logged in, but it didnt work. The question is, is there a way around the security using the USER_ID within the cookie to fool the script, My script checks the USER_ID within the cookie to make sure it exists in the database, it also makes sure that the useragent matches the real user incase of hyjacking, is this enough? Thanks in adavance, Looking forword to hearing your replys.
August 13, 201016 yr User agents can be played with and faked so shouldn't always be relied on. Also some browsers can change it for no reason *looks at IE* which can be a pain for your users. It's usual to store some kind of extra information in the cookie that can't be guessed easily, like a random key which you also save against the user and then check userID and this key each time they visit. That way even if someone used someone elses User ID and copied their user agent somehow in this case, they wouldn't know about their unique key so would definately fail!
August 13, 201016 yr hey, Cheak out In addition to the privacy issues, cookies carry security implications as well. Many sites use cookies to implement access control schemes ... ____________________________________________________________________________________ Want to get-on Google's first page and loads of traffic to your website? Hire a SEO Specialist from Ocean Groups
August 14, 201016 yr Author hey, Cheak out In addition to the privacy issues, cookies carry security implications as well. Many sites use cookies to implement access control schemes ... No ****, Your kidding me right? I wounder how they did this? DUHHH
August 14, 201016 yr Store the users password and username in the cookie and then check it against what you've got in the database. Encrypt everything in the cookie and then decrypt it server side and check the information against the database. (see: http://uk2.php.net/mcrypt) In some cases you can just store everything in the users cookie and remove the need of storing session files on your server (this also has other advantages regarding to scalability)
August 15, 201016 yr Author Store the users password and username in the cookie Are you out of your mind? What id the computer is shared? or the cookie gets hyjacked?
August 15, 201016 yr Are you out of your mind? What id the computer is shared? or the cookie gets hyjacked? I think you're slightly confused at what a cookie is, you do know a Cookie is used for sessions right? I suggest before you tell me i'm out of mind you actually learn how things work. You seem to be calling me the insane one when you're actually storing the user id in the cookie and then logging the user in based on it... I could easily create a cookie on my local machine with the user id of 1 and most likely get access to your administrator account. Cookies are client side - NEVER trust client side data. I also suggest you hire someone else to make your system secure - as you seem to know little about the basics.
August 15, 201016 yr I have an access key set up. Basically it's a random string which is generated every time the account is logged into/logged out of. There really isn't much to compare it to, however it works decently. In my admin panel I can forcefully log the user out (AKA change the access key). This is only compared with the user id. You can't really compare it to any other information because peoples IP addresses change all the time. But I suppose you could do that. If the IP address changes, force the user to re-login. AKA <?php if($_SERVER['REMOTE_ADDR'] != $ip_from_database){ // kill the cookie // change access key } ?> Then as the user logs in, change the access key again as well as the IP address on file. If you find out any decent answers, let me know as well... I could always use a security upgrade.
August 15, 201016 yr - Do use HttpOnly on cookies (http://uk.php.net/set_cookie) - Don't use the users IP as a way of verifying sessions - Regenerate the users SESSIONID when permissions are changed (i.e. login as administrator) - Make sure sessions timeout. - Store $_SERVER['HTTP_USER_AGENT'] against the users session - this will add another hurdle for the hacker. - Use an SSL across the entire site - There's no point in just using it for when the user logs in, as a hacker will just sniff the network on the first non-https connection.
Create an account or sign in to comment