SilentChamber
09-01-2006, 03:19 PM
Hello,
Here's my problem,
I'm working on my gallery script and my cookies don't seem to work, I am not sure if it has anything to do with the fact that i'm using mod_rewrite or not.
i've used this code on several sites of mine and they all work fine. my friend recommended to make an OOP version of it, but i'm not so sure how to i know basic OOP but not enought to make anythign with it.. anyway here's my code.
login.php
<?php
if($remember == "on") {
$cookiedata = $r->username.'-'.$r->password;
setcookie("******-*****", $cookiedata, time()+31536000);
}
?>
header.php
<?php
if(isset($_COOKIE['******-*****'])){
$cookiedata = explode("-", $_COOKIE['******-*****']);
$cookie_user = $cookiedata[0];
$cookie_pass = $cookiedata[1];
$query_user = "SELECT * FROM `users` WHERE `username` = '$cookie_user' AND `password` = '$cookie_pass'";
$exec_user = mysql_query($query_user) or die(mysql_error());
if(mysql_num_rows($exec_user) == 0) {
header('location: http://www.silentchamber.co.uk/index/');
require('inc/footer.php');
exit;
}
else {
while($r_user=mysql_fetch_object($exec_user)){
$userid = $r_user->id;
$username = $r_user->username;
$userdisplay = $r_user->displayname;
$access = $r_user->access;
}
session_register('******-*****');
$_SESSION['username'] = $username;
$_SESSION['displayname'] = $userdisplay;
$_SESSION['userid'] = $userid;
$_SESSION['useraccess'] = $access;
}
}
?>
reason why i think it is the mod rewrite causing the problem because i've noticed that in the dir with header.php it works but header is included into the index.php file..
hope someone can help me with this.
Regards,
Neil Hickman
Company Director, SilentChamber Photography <silentchamber.co.uk>
Here's my problem,
I'm working on my gallery script and my cookies don't seem to work, I am not sure if it has anything to do with the fact that i'm using mod_rewrite or not.
i've used this code on several sites of mine and they all work fine. my friend recommended to make an OOP version of it, but i'm not so sure how to i know basic OOP but not enought to make anythign with it.. anyway here's my code.
login.php
<?php
if($remember == "on") {
$cookiedata = $r->username.'-'.$r->password;
setcookie("******-*****", $cookiedata, time()+31536000);
}
?>
header.php
<?php
if(isset($_COOKIE['******-*****'])){
$cookiedata = explode("-", $_COOKIE['******-*****']);
$cookie_user = $cookiedata[0];
$cookie_pass = $cookiedata[1];
$query_user = "SELECT * FROM `users` WHERE `username` = '$cookie_user' AND `password` = '$cookie_pass'";
$exec_user = mysql_query($query_user) or die(mysql_error());
if(mysql_num_rows($exec_user) == 0) {
header('location: http://www.silentchamber.co.uk/index/');
require('inc/footer.php');
exit;
}
else {
while($r_user=mysql_fetch_object($exec_user)){
$userid = $r_user->id;
$username = $r_user->username;
$userdisplay = $r_user->displayname;
$access = $r_user->access;
}
session_register('******-*****');
$_SESSION['username'] = $username;
$_SESSION['displayname'] = $userdisplay;
$_SESSION['userid'] = $userid;
$_SESSION['useraccess'] = $access;
}
}
?>
reason why i think it is the mod rewrite causing the problem because i've noticed that in the dir with header.php it works but header is included into the index.php file..
hope someone can help me with this.
Regards,
Neil Hickman
Company Director, SilentChamber Photography <silentchamber.co.uk>