Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > PHP Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-30-2009, 02:32 PM
  #1
blackpepper
Gampi
 
blackpepper's Avatar
 
Join Date: Jul 2005
Location: metro
Posts: 1,233
iTrader: (0)
blackpepper will become famous soon enough
PHP Sessions Question

For building a login, I obviously want the person to stay logged in after they have done so.

At the logging in script, a session variable is set
PHP Code:
    $_SESSION['SESS_MEMBER_ID'] = $member['username']; 
then on my authorization page(which is included into various subpages which require a user to be logged in) I check to see if that variable is set
PHP Code:
<?php
    
//Start session
    
session_start();
    
    
//Check whether the session variable SESS_MEMBER_ID is present or not
    
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
        
header("location: //Members");
        exit();
    }


?>
Is doing something like this completely safe? Can this session variable be generated by someother way, and then used to falsely authorize the user? I would appreciate an explanation If I need to add a level of security, a point in the right direction would be great

Cheers,
BP
__________________
blackpepper is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 10-31-2009, 06:37 PM
  #2
scoutt
Mister Admin to you
 
scoutt's Avatar
 
Join Date: Jul 2001
Posts: 30,730
iTrader: (0)
scoutt is a jewel in the roughscoutt is a jewel in the roughscoutt is a jewel in the rough
well that is what most people do. I fyou r cookies are safe then it should be okay to do it that way.
__________________
Have a Script or Snippet you want to share?

WWW Standards: HTML 4.01, CSS2.1, CSS3, XHTML 1.0
PHP Standards: PHP Standards
scoutt is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 11-01-2009, 01:18 PM
  #3
blackpepper
Gampi
 
blackpepper's Avatar
 
Join Date: Jul 2005
Location: metro
Posts: 1,233
iTrader: (0)
blackpepper will become famous soon enough
thank you scoutt. I have been reading documentation about php sessions it's just somewhat confusing stuff for me.

So my final question/thought:
Say I had a session started with a variable of SESS_MEMBER_ID , however htmlforums.com had also used the same variable name to store login auth. Why is it that storing the session on ONE site does not sign you in on another site. Are the session variables unique per domain they are started at? And is that something which cannot be manipulated, thus generating a false session to log yourself in would be impossible?

If it sounds like I am a bit confused please let me know, I really would like an understanding of all of this stuff

Cheers,
BP
__________________
blackpepper is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 11-01-2009, 08:15 PM
  #4
scoutt
Mister Admin to you
 
scoutt's Avatar
 
Join Date: Jul 2001
Posts: 30,730
iTrader: (0)
scoutt is a jewel in the roughscoutt is a jewel in the roughscoutt is a jewel in the rough
yes, sessions are unique to its own server.
__________________
Have a Script or Snippet you want to share?

WWW Standards: HTML 4.01, CSS2.1, CSS3, XHTML 1.0
PHP Standards: PHP Standards
scoutt is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


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



 
  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 Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 06:24 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.