Buglish Posted September 22, 2006 Share Posted September 22, 2006 Hi I have made this basic model for all pages in my website.-Will this be too much overhead processing and improper space utilization?-Is this a terrible way to authenticate the user and have different classes of login functions?[code]<?php session_start();?><html> <head> <title>Title</title> </head> <body> <?php include "../bin/db.php"; $pagelink = $_GET['pagelink']; $submit = $_POST['submit']; $username =""; $password=""; $loginType=0; function Learner() { global $submit,$pagelink,$username,$password,$loginType; } function Guest() { global $submit,$pagelink,$username,$password,$loginType; } function Instructor() { global $submit,$pagelink,$username,$password,$loginType; } function Admin() { global $submit,$pagelink,$username,$password,$loginType; } // -----------Start of Main Code-------- if (!isset($_SESSION)) //Create or retrieve session variables { $_SESSION['username']="Guest"; $_SESSION['password']="Guest"; $_SESSION['logintype']=0; echo $_SESSION['username']; echo $_SESSION['password']; } else { ?> You are Logged on.<br> <?php $username = $_SESSION['username']; $password = $_SESSION['password']; $loginType = $_SESSION['logintype']; } switch($loginType) { case 0 : Guest(); break; case 1 : Learner(); break; case 2 : Instructor(); break; case 3 : Admin(); break; default : Guest(); break; } ?> </body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/21642-php-session-authentication-question/ Share on other sites More sharing options...
steveclondon Posted September 22, 2006 Share Posted September 22, 2006 Is it working, if so looks fine to me. I have several sites that run a few pages of different information before it gets into doing anything I can't see this causing a major load on the server at all, if that is what you mean . Link to comment https://forums.phpfreaks.com/topic/21642-php-session-authentication-question/#findComment-96581 Share on other sites More sharing options...
Buglish Posted September 22, 2006 Author Share Posted September 22, 2006 Hi,Yes I was worried that my first design of sessions looks a bit flimsy or not robust enough.I am new to PHP so I am not sure how to approach this matter.Thanks for the Info. Link to comment https://forums.phpfreaks.com/topic/21642-php-session-authentication-question/#findComment-96588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.