View Full Version : Problems with Cookies and Skins
yamikarasu
05-07-2003, 09:33 PM
Okay, I've got everything coded but I'm having problems getting the cookie to recognize a change in the skin. It just stays at the default and won't change when told
domesticat.net is where I got the tutorial for all of this, but like said, everything works but the changing of layout (or css, rather) skins. The site is negative.mystic.nu that has all this..
firepages
05-08-2003, 11:00 AM
echo () the value of your cookies to see if they are indeed being set or not , either way an example of the code would be useful to helkp diagnose + the phpversion & whether your host has register_globals turned on or off.
yamikarasu
05-08-2003, 09:54 PM
I don't know the php version or register_globals thing... I can ask my hostess though, if it's really important...
Here's the "cookiecheck.php" code:
<?
$total_skins = 3;
$default_skin = 1;
if (isset($_REQUEST['newskin'])) {
$newskin=(int)$_REQUEST['newskin'];
if ( ($newskin<1) OR ($newskin>$total_skins) ) $newskin=$default_skin;
} elseif (isset($_REQUEST['skin'])) {
$newskin=(int)$skin;
if ( ($skin<1) OR ($skin>$total_skins) ) $newskin=$default_skin;
} else $newskin=$default_skin;
$skin=$newskin;
setcookie ('skin', "", time() - 3600);
setcookie('skin',$newskin,time()+(86400*365),'/');
setcookie('skin',$newskin,time()+(86400*365),'/','.negative.mystic.nu');
$skin=$newskin;
$headervar = "/home/mystic/public_html/negative/skins/top";
$footervar = "/home/mystic/public_html/negative/skins/Back";
$Seperatorvar = "/home/mystic/public_html/negative/skins/Seperator";
$extension = ".txt";
?>
And then here's the coding for the page that's supposed to tell it which skin to look to:
<body topmargin="0" bottommargin="0" leftmargin="0" marginwidth="0" marginheight="0" bgcolor="white" scroll="no">
<p align="center"><img SRC="splash.jpg" ALT="Soul Searching..." width=455 height=314 BORDER=0 usemap="#Map">
<map name="Map">
<area shape="rect" coords="30,25,134,147" href="/Heaven/index.php?newskin=1" alt="On Feathered Wings">
<area shape="rect" coords="154,39,263,148" href="/Purgatory/index.php?newskin=2" alt="Undecided is my Fate">
<area shape="rect" coords="284,40,388,160" href="/Hell/index.php?newskin=3" alt="Damned It All to Hell">
</map>
</p>
yamikarasu
05-08-2003, 09:56 PM
Oh, and I do have that cookiecheck.php included into the file that specifies the skins.
missing-score
05-11-2003, 09:41 AM
<?
if (isset($_GET['newskin'])) {
$newskin=(int)$_GET['newskin'];
if ( ($newskin<1) || ($newskin>$total_skins) ) {
$newskin=$default_skin;
}
} elseif (isset($_GET['skin'])) {
$newskin=(int)$skin;
if ( ($skin<1) || ($skin>$total_skins) ) {
$newskin=$default_skin;
}
} else {
$newskin = $default_skin;
}
?>
Change to that, it should work...
Oh, and you are setting 3 cookies with the same name. I assume the first one is deleting, but the next 2 are similar and have the same name.
<?php
setcookie ('skin', "", time() - 3600); // Delete...
setcookie('skin',$newskin,time()+(86400*365),'/','.negative.mystic.nu');
?>
Try that.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.