Forum Moderators: coopster
got a little problem with a session script. used to work all those months ago...
anywa using sessions to let the site visitor choose aa skin for my site. the code is as follows:
to set session:
<?php
session_start();
//check if 'skin' is set
if(!isset($_GET['skin']))
{
$skin = 'flyaway_yellow3.css';
}
else{
$skin = $_GET['skin'];
}
// Register session key with the value
$_SESSION['skin'] = $skin;
header("Location: " . $_SERVER['PHP_SELF']);
?>
on each skinnable page:
<?php
session_start();
//session code
//header('Cache-control: private'); //IE 6 Fix
if ( isset($_SESSION['skin']) ) {
$skin = $_SESSION['skin'];
}
else {
$skin = "flyaway_yellow3.css";
}
//end session code
//start art code
if(isset($_GET['art']))
{
if ($_GET['art']=='index.php3')
{
$art='index.txt';
}
else
{
$art= $_GET['art'];
}
}
else{
$art='index.txt';
}
?>
dont think the last bit here is relevant, but i put it here just in case. using it to load content.
so far i dont think ive done anything wrong. but i get the following messege from firefox and ie doesnt even load....well it takes forever and i never bothered to wait..any help aprecited. is it that the header redirection is somehwat 'wrong' here?
this is the messege from ff:
redirection limit for this url exceeded. unable to load requested page. this may be caused by cookies thta are blocked.
thanks
kumar
this is the links im using to call the script to set the session...
<p>
<a href="setskinvalue.php3?skin=boeing.css">
Boeing</a>
<br />
<a href="setskinvalue.php3?skin=flyaway_yellow3.css">
Fly Away</a>
</p>
looking at ies behaviour, it seems like its entered a forever loop. so maybe im not understanding the use of
header("Location: " . $_SERVER['PHP_SELF']);
What I'd do if I were you is: make the link to switch skins point to this page, with not only the new skin set as a parameter, but also the originating page set as a parameter. Make the location header then point to this originating page; and if for some reason it's not set, make it point to the home page or an error page.
You've been learning a lot of php lately, kumarsena! ;)
that should work i guess.
thanks alot for ur input there...ill look into ur suggestions.
yeah, alot of php, the well of php never seems to empty, so iguess its a lifelong learning process...he he he