Code2Design.com

User login

The Layout

Programming

Graphic Design

Resources

Navigation

C2D Projects

Unsystematic Affiliates

AOM Designs Player-Art Tutorials-db Tutorial Search 

Change Language

Who's online

There are currently 0 users and 12 guests online.

Secure Session's

Ok, I am trying to make as secure of a script as I can without using SSL. I found a page on it (http://www.devarticles.com/c/a/MySQL/Security-and-Sessions-in-PHP/ ) and I want to know if this is right:

Say I have a user table something like like this:

CREATE TABLE users (
username varchar(255) NOT NULL,
email varchar(255) NOT NULL,
password varchar(255) NOT NULL,
sid varchar(32),
)

Every time someone logs in I create a SID value and stick one copy in the user's database table and another in a cookie to give back to the user. Then every time a page is requested I check the session ID in the cookie against the one in the database and if it is found then I let them in. Now, is there anything else that I could do to make the session ID more secure?

Since I want to store these in a database so do I need to make my own session functions?

Should I make a new table and call it sessions and make have it contain the SID and userID?

Also, I have lots of strlen(), mysql_real_escape_string(), gettype(), etc... functions to clean the values so don't worry about that. I just want to know how to keep the user's sessionID from being hijacked by a hacker.

Ok, here is some more reading if anyone else is interested:
Store Session Data in a MySQL Database
Download Chaper 4 of phpsecurity
Trick-Out Your Session Handler
PHP 101 (part 10): A Session In The Cookie Jar
Session Handling with PHP 4


Submitted by David on February 10, 2007 - 3:54am.
printer friendly version

sessions table

Hey,

Should I make a new table and call it sessions and make have it contain the SID and userID?

I would create a new table for sessions with just the userID and the SID. There will be a lot less searching for the DB to do. The user table that you posted as an example would have to search the 4 key in each row to find the right one. With a session table it would only have 2 keys to sort through.

by the way... I love the new site

God Bless,

StarTrak118


Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <br /> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use BBCode tags in the text, URLs will be automatically converted to links
More information about formatting options



Like what you see?

Why not add more? C2D is looking for other Christian Web Masters who would like to help write articles for this site. If you have expericance in FLASH, CSS/HTML, PHP/MySQL, PhotoShop/GIMP, Blender, Javascript, or just General Design - our users would love to hear what you have to say. Contact Us

delicious   digg   reddit   magnoliacom   newsvine   furl   google   yahoo   technorati