| | |||||
| ||||||||
| CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Account Suspended Join Date: May 2004 Location: /etc/passwd
Posts: 2,178
![]() ![]() ![]() ![]() ![]() ![]() | dbSESSIONS In the creation of a new authentication system i made for an upcoming website, i have created a way that does not use a cookie or a regular session using a database. Code: PHP Code: Code: DROP TABLE IF EXISTS dbsessions; CREATE TABLE dbsessions ( sessionID varchar(32) NOT NULL default '', ipaddress varchar(20) NOT NULL default '', setdate varchar(255) NOT NULL default '', daystokeep int(11) NOT NULL default '0' ) TYPE=MyISAM; DROP TABLE IF EXISTS session_vars; CREATE TABLE session_vars ( sessionID varchar(32) NOT NULL default '', var text NOT NULL, value text NOT NULL ) TYPE=MyISAM; PHP Code: Code: $dbses->register(); Code: $dbses->variable("ip","$ip"); How this works This is really a way to keep data retrieval away from the client side... they will have to get server access to get any information. The register() function will setup a new sessionID in the dbsessions table, and its retrieved by the users ip address. All the data is accessed using the viewers ip address. This is only the basics of this idea, i recoded this for here at namepros, so if there is any problems just ask me, and id be glad to assist you. What this would be useful for: Web games, email services, things like that. Is this secure? In my opinion it is, the only thing that could make this insecure was the person uses a shared proxy ip address. Good thing to keep in mind: Two DIFFERENT people cannot be logged in on the same ip address at a time. To me, this could prevent a lot of cheating online games, without the use of a GOOD proxy application, cause it does look for ip forwarding. Any questions/comments post here. |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: Oct 2005 Location: India
Posts: 608
![]() ![]() ![]() ![]() | I'm not too sure this is the right way to go ... the use of an IP address as the only means to validate a session is dangerous... also think of AOL users... moreover, when you have an in-built mechanism in PHP for creating session IDs why not use that ?? If you're apprehensive about storing the actual session data (which can be anything like username, user preferences, etc) in a flat file, store this session data in a mysql database... but you should use session_start() as the way to let PHP itself create session IDs for you .....
__________________ My blog (beta) Bachelor.co.in - Gemstone.co.in Assets.co.in - PropertyDealers.org MortgageFirms.org - eLearner.org |
| |