in many of my here ive been trying to find a way to connect to a database via a single user on a site pull up information based on his login so he can veiw his own personal files...
the more i snooped around reading post, replying, and asking via new posts the unifying thought of sessions connected my inquiries to the inquiries of others, so this weekend i looked up the subject in the php manual and came across the following code snippet...it seems as though the example is spit up into fuctions to be
used througout coding of the page...i understand that much...but alot of it i just dont get...i have broken the
snippet up by functions in order to ask the questions im not understanding
Code: Select all
<?
class Session
{
function _makeid()
{
$time = time();
$ip = $_SERVER["REMOTE_ADDR"];
$agent = $_SERVER["HTTP_USER_AGENT"];
$md5 = md5($time.$ip.$agent);
setcookie("SClass", $md5);
return($md5);
}login screen...like say that this code is on the page the user gets after he logs in...how would this pertain to
specifically him vs anyone else? what exactly does this code do?
Code: Select all
function getid()
{
$md5 = $_COOKIE['SClass'];
return($md5);
}
function start()
{
$id = $this->getid();
if (!$id) { $id = $this->_makeid(); }
}
function _getfile()
{
$file = $this->getid();
$file .= ".ssn";
$file = "[--PATH-TO-SESSION-FOLDER--]".$file;
return($file);
}function $md5 is set to a cookie then its value being returned
i really dont understand the start function at all but if i were to take a guess it looks like the $ID that was made in the previous function is being set to the current one...if not then make it that way(once again guessing)
waht is the get file function for? what is it supposed to do? in the manual before the posted snippet
the author wrote
why and how would you use a folder if the information on the page is all being pulled from the database?Before use, you must replace "[--PATH-TO-SESSION-FOLDER--]" with the path to where sessions should be stored. Make sure to set the proper permissions for that folder
the rest of the code i didnt include because i was hoping to get an explanation for this first