RE: [PHP] Keeping URL Variables

From: Date: Sat, 19 Apr 2003 00:52:55 +0000
Subject: RE: [PHP] Keeping URL Variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-144455@lists.php.net to get a copy of this message
> Is there a way to keep a URL variable every page you go to without editing > the <a> tag's href attribute everytime? > > Basically, I have skin options and depending on what the URL variable > "skinid" is, it shows that skin (I have multiple websites all using this > PHP script). What I want to be able to do is get the value of skinid, then > if the user goes to another page via a link or form, that skinid is still > chosen. What's happening right now is if a user clicks a link, the skinid > in the URL is nolonger set so it defaults to the default skin. > > Is there a way to always pass the variable to any part of the side through > a global include without having to put it in the URL in the <a> tag every > time? Use cookies or sessions. Session_start(); $_SESSION['skinid'] = 4; Now you can use the variable $_SESSION['skinid'] on any page that has session_start() on it. Switch($_SESSION['skinid']) { case 4: include('blue-skin.php'); break; case 3: include('red-skin.php'); break; } etc... Cookies would be a similar method using the setcookie() function. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.general (#144455) next »