Danny620 Posted July 7, 2009 Share Posted July 7, 2009 i have a log-in system where it stores a session named 'agent' which store HTTP_USER_AGENT and what i have done is made a file named gatekeeper and what that does is check that the session is set and that it matches the md5 HTTP_USER_AGENT session if none are true then it directs them to the log in page is this a good way to protect pages this is my gatekeeper file <?php //lockdown and check for login if (!isset($_SESSION['agent']) or ($_SESSION['agent']) !== md5($_SERVER['HTTP_USER_AGENT'])) { require_once ($_SERVER['DOCUMENT_ROOT'].'/login_functions.inc.php'); $url = absolute_url(); header("Location: $url"); exit(); } else { // everythings ok } ?> Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/ Share on other sites More sharing options...
Danny620 Posted July 7, 2009 Author Share Posted July 7, 2009 and the pages i want protecting i put this on require_once($_SERVER['DOCUMENT_ROOT'].'/access/gatekeeper.php'); Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-870622 Share on other sites More sharing options...
cunoodle2 Posted July 7, 2009 Share Posted July 7, 2009 So whats your question then... Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-870624 Share on other sites More sharing options...
Danny620 Posted July 7, 2009 Author Share Posted July 7, 2009 my question is is this code hacker free and a good method of protecting pages Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-870627 Share on other sites More sharing options...
Daniel0 Posted July 7, 2009 Share Posted July 7, 2009 What is there to "hack" in your code snippet? DOCUMENT_ROOT comes directly from the web server. Or am I not getting things here? Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-870632 Share on other sites More sharing options...
Danny620 Posted July 7, 2009 Author Share Posted July 7, 2009 is it possable for someone to hack a fake session Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-870661 Share on other sites More sharing options...
batfink1 Posted July 7, 2009 Share Posted July 7, 2009 Well no code is "hacker free" but yeah as long as your site isn't holding really secure data then your method should be fine. Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-870670 Share on other sites More sharing options...
Danny620 Posted July 8, 2009 Author Share Posted July 8, 2009 thanks for that but if i where to pull the data based on the userid could any user once logged in change there userid in the session Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-871093 Share on other sites More sharing options...
Daniel0 Posted July 8, 2009 Share Posted July 8, 2009 No. Session data is stored on the server. Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-871101 Share on other sites More sharing options...
WolfRage Posted July 8, 2009 Share Posted July 8, 2009 The user can not change any session information unless you allow them to. The session data is stored on the server. However if you are using a shared host any other webmaster on that server could see and modify this data. Thus you should create your own secure area for your sessions. Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-871104 Share on other sites More sharing options...
Danny620 Posted July 8, 2009 Author Share Posted July 8, 2009 thank you alot but 1 more question i i where to have code on the pages i wanted to be protect only for login members would it be ok if i used a if(!isset($_session['agent'])){ then return them to loggin page } else { //is logged in would that be secure enouth to protect my pages against not logged in members. Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-871108 Share on other sites More sharing options...
Danny620 Posted July 8, 2009 Author Share Posted July 8, 2009 is a webmaster the person incharge of the sever that i am hosting on? Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-871110 Share on other sites More sharing options...
WolfRage Posted July 8, 2009 Share Posted July 8, 2009 For your code that depends on how you are validating if they are allowed to be an agent. No webmaster is any other person that has hosting on the same shared server as you. For instance your friend Dan could be paying the same company for hosting and they may put you both on the same shared server. Now if he is smart he can access all of your session data that is stored in the same default location as his session data. Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-871116 Share on other sites More sharing options...
Danny620 Posted July 8, 2009 Author Share Posted July 8, 2009 so how would i go about protecting my sessions and whats SSL where that padlock is in the conner how do i implay that into my code Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-871316 Share on other sites More sharing options...
Daniel0 Posted July 8, 2009 Share Posted July 8, 2009 so how would i go about protecting my sessions Store them in a non-publicly accessible directory or create a session handler that stores in a database instead. and whats SSL where that padlock is in the conner how do i implay that into my code http://en.wikipedia.org/wiki/Secure_Sockets_Layer http://en.wikipedia.org/wiki/HTTPS Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-871321 Share on other sites More sharing options...
Danny620 Posted July 8, 2009 Author Share Posted July 8, 2009 thanks for all these comments they have help me alot :) :) Quote Link to comment https://forums.phpfreaks.com/topic/165108-solved-security-question-need-solving/#findComment-871369 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.