htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: PHP Session Var From .Htaccess
PostPosted: 29 Feb 2008 18:56 
Offline

Joined: 29 Feb 2008 18:50
Posts: 1
is it possible to set a PHP session var from htaccess

Code:
                RewriteCond %{QUERY_STRING} (.*)?varname=(.*)?
                RewriteRule .? - [php_value=varname:varval]


i know we can create an environment var but i would prefer to set a session var before redirecting..

Thanks


Top
 Profile  
 
 Post subject: PHP Session Setting with .htaccess
PostPosted: 26 Mar 2008 19:27 
Offline

Joined: 28 Feb 2007 17:16
Posts: 40
Sortof, it depends on what kind of session settings you have setup.


You can use code like this to set a session variable, though it requires the client to request it, or you could set a normal cookie using the instructions elsewhere on the forum, and check for that to create a session var after redirection.


Code:
<?php
ob_start();
$token = md5($_SERVER['REMOTE_ADDR']);
if(!isset($_SESSION['token'])||$_SESSION['token']!==$token)$_SESSION['token'] = $token;
$value="isplaying+on|FontSize+foSL|MP3+on|MP31+1";
setcookie("ASKAPACHEP", $value, time()+86400, "/", ".askapache.com");
$res='R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
$c=base64_decode($res);
header('Content-Length: '.strlen($c));
header('Content-Type: image/gif');
echo $c;
exit;
?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB