The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> HTML Programming
|
Cookies
Discuss Cookies in the HTML Programming forum on Dev Shed. Cookies HTML Programming forum covering discussions of HTML and XHTML, as well as HTML-related issues such as writing W3C Compliant code. Use HyperText Markup Language for building websites.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

July 30th, 2012, 02:19 PM
|
|
Registered User
|
|
Join Date: Jul 2012
Posts: 4
Time spent in forums: 1 h 31 m 9 sec
Reputation Power: 0
|
|
|
Cookies
I am taking what I have learned my last semester to try and build my own website. I am working on a login for different users and want to know what the best practice would be.
If I use cookies to check if a user is logged in what data should I store in the cookie after the user signs in to check. I figured I wouldnt want it to be just there user name because anyone could just make that cookie themselve and log in as that user....
Any ideas woudl be greatley appreciated. I am not storing really any sensitive material on my website so it does not need to be bank secure.
|

July 30th, 2012, 02:48 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
|
Hi,
First of all, you should make up your mind if you actually want to offer user registration. Saying that security isn't that important for you sounds like this is going in a wrong direction.
If you just want to make the page customizable, then you don't need user accounts. Simply store the values in cookies. But if you do want to store personal information like email addresses, password information etc., then security is important.
Login information is usually stored in sessions. The functions for that are most probably already built-in in your language (whatever it is you are using).
As I already said, security is in fact very important. So you really should know how everything works before you actually start with the implemention. A particularly critical issue is of course password managment, because there's a lot you can do wrong here. And since users tend to reuse their passwords everywhere, you want to make sure you don't f*** up in securing them.
Never store passwords in plaintext or as simple hashes. The absolute minimum is to use salted hashes. A better apporach is to use specialized algorithms like PBKDF2 or bcrypt.
|

July 30th, 2012, 03:10 PM
|
|
Registered User
|
|
Join Date: Jul 2012
Posts: 4
Time spent in forums: 1 h 31 m 9 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by Jacques1 Hi,
First of all, you should make up your mind if you actually want to offer user registration. Saying that security isn't that important for you sounds like this is going in a wrong direction.
If you just want to make the page customizable, then you don't need user accounts. Simply store the values in cookies. But if you do want to store personal information like email addresses, password information etc., then security is important.
Login information is usually stored in sessions. The functions for that are most probably already built-in in your language (whatever it is you are using).
As I already said, security is in fact very important. So you really should know how everything works before you actually start with the implemention. A particularly critical issue is of course password managment, because there's a lot you can do wrong here. And since users tend to reuse their passwords everywhere, you want to make sure you don't f*** up in securing them.
Never store passwords in plaintext or as simple hashes. The absolute minimum is to use salted hashes. A better apporach is to use specialized algorithms like PBKDF2 or bcrypt. |
thanks, I do need a login because I am keeping track of certain data that a user would want to be able to pull up on any computer.
I will explore sessions in html and perl.
Thank you!
|

July 30th, 2012, 03:19 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Quote: | Originally Posted by searayman thanks, I do need a login because I am keeping track of certain data that a user would want to be able to pull up on any computer. |
This can be done with cookies or sessions without a real login.
An actual login with password authentication is only necessary if you are storing critical data or user identification is very important (like when users are allowed to submit content).
|

July 30th, 2012, 08:01 PM
|
 |
Lost in code
|
|
|
|
|
If he wants to track data for the user across multiple computers then a registration system makes more sense than storing it in cookies.
|

July 30th, 2012, 09:54 PM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
|
I disagree. Since he said the data isn't critical and he doesn't want to put much effort in security, I think a registration system is actually a bad idea. It's too complicated and will most likely be insecure, exposing all user data (email addresses, passwords) to the next best script kiddie.
I'd rather use public user profiles in this case (the data can be saved in a profile and reloaded -- the ID is stored in a cookie or session). Then you don't have to worry about password hashing etc., and every user knows his data isn't protected.
If, on the other hand, you want to store private data, then of course you should use a registration system.
So it depends. But what you should never do is to offer a registration system and at the same not really care about security. That's just dangerous and also dishonest with respect to the users.
I think data should be either public or private, but not "halfway private"
|

August 9th, 2012, 12:16 PM
|
|
Contributing User
|
|
Join Date: Dec 2006
Location: IL, USA
|
|
|
1) COOKIES and SESSIONS are not HTML related, they are a client-side thing that you should use a language like PHP to handle.
With that said, I do a number of things for my cookies/sessions.
There is a number of ways you can handle this, you can have a field like $_COOKIE['user'] that returns the user's username, or whatever unique identifier you have, this way you can always grab their data per page, and if this is empty you can assume they are not logged on?
I always have a SESSION part inside of the "users" table in my database that I have md5 / sha1 (hashing encryptions) that store non-personal and critical data and store this into the cookie. this way I can always use that to grab the entire user after - which once "logged in" the normal / common data I grab (username, first_name, access lvl (admin|user|etc.)) can all get stored into my SESSION (not cookie) and then I can grab that all the time.
it's all a preference on you and how you want to use / manage your system.
|

August 9th, 2012, 02:19 PM
|
 |
CSS & JS/DOM Adept
|
|
Join Date: Jul 2004
Location: USA
|
|
Quote: | Originally Posted by AvsH COOKIES and SESSIONS are not HTML related, they are a client-side thing that you should use a language like PHP to handle. |
Don't you mean "server-side"? 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|