TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-18-2007, 08:45 PM   #1 (permalink)
The Wanderer
Newcomer 
 
Join Date: Nov 2007
Posts: 14
Thanks: 1
MartynMJ is on a distinguished road
Default My login method?

I've never "Learnt" how to make a login script just sort of assumed how to do it so i was wondering if my way was bad lol, here's a description.

Username and password stored in database (password md5'ed).

When the user attempts to login then it will check the database to see if the info matches.

If all is well at this point then in a sessions table it will insert the username, a random code and there IP address.

Then a cookie is set with a base64 encoded serialized array, in the array is the id of the session in the database, username and random code.

Then if they try to view a members page it will check that the info from the cookie and the users ip address matches that in the database.

Is this bad ? lol

Make sense? :)
MartynMJ is offline  
Reply With Quote
Old 11-22-2007, 10:52 AM   #2 (permalink)
The Acquainted
 
EyeDentify's Avatar
 
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
EyeDentify is on a distinguished road
Default

Im no expert, but one should be a little carefull with trusting that the IP stays the same at all times.

I would not rely on that.

And the IP could be the Same for a multitude of users if there from the same ISP for example.

Anyone else ?
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
EyeDentify is offline  
Reply With Quote
Old 11-22-2007, 12:45 PM   #3 (permalink)
The Wanderer
Newcomer 
 
Join Date: Nov 2007
Posts: 14
Thanks: 1
MartynMJ is on a distinguished road
Default

Quote:
Originally Posted by EyeDentify View Post
Im no expert, but one should be a little carefull with trusting that the IP stays the same at all times.

I would not rely on that.

And the IP could be the Same for a multitude of users if there from the same ISP for example.

Anyone else ?
Yes i know that relying on an IP address wouldn't really do but no only does the IP address have to be the same but the ID of the user session, the username and the random code which is encoded has to match the database record so i figured it would be extremely hard for a hacker to get a row inserted into the database with there random code and so on?
MartynMJ is offline  
Reply With Quote
Old 11-22-2007, 02:10 PM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,258
Thanks: 90
Wildhoney is on a distinguished road
Default

Trouble is with the IP address is that some ISPs, such as AOL, their IP changes on every page request and so any end-user on your website using AOL, or other ISP that go down the same route with their IPs, would be required to login in every single time.

Moreover, for your passwords you'll no doubt be wanting to apply a salt to them and then MD5ing them together.

Working with Dynamic Cryptography Salts
Cryptography's Sodium Chloride
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 11-23-2007, 10:33 AM   #5 (permalink)
The Wanderer
Newcomer 
 
Join Date: Nov 2007
Posts: 14
Thanks: 1
MartynMJ is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Trouble is with the IP address is that some ISPs, such as AOL, their IP changes on every page request and so any end-user on your website using AOL, or other ISP that go down the same route with their IPs, would be required to login in every single time.

Moreover, for your passwords you'll no doubt be wanting to apply a salt to them and then MD5ing them together.

Working with Dynamic Cryptography Salts
Cryptography's Sodium Chloride
I have been using a salt on the passwords :).

Does any one have a link to a tutorial where they have a good method for user sessions?
MartynMJ is offline  
Reply With Quote
Old 01-01-2008, 07:36 AM   #6 (permalink)
The Wanderer
 
thegrayman's Avatar
 
Join Date: Dec 2007
Posts: 15
Thanks: 3
thegrayman is on a distinguished road
Default

What I was thinking about was setting multiple cookies, one with session id and other info serialized as well as another setting a value that is updated in the db everytime the user changes pages. I plan to check to see if cookies can be set, if not then sending them to a page explaining that you need to have cookies turned on to use this site sort of thing. Obviously when someone logs in regenerate their session id at time as well.
thegrayman is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:10 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design