Forum Moderators: coopster
I was wondering if someone can help me out on this issue.
I wrote a little PHP script that sets a cookie and then forwards the user to the appropriate page. Everything works fine until I use the mod_rewrite version of the URL. The cookie can not be read (and I don't know how to tell if it's set in the first place).
Here is some code:
linktrack.php (e.g. mydomain.com/linktrack.php?id=1)
// Get the query string value
$id = $_GET['id'];
// Set the cookie
setcookie('linktrack', $id, time()+3600*24*90);
linktracktest.php
if (!$_COOKIE['linktrack'] ) {
print 'cookie does not exist';
}else {
$id = $_COOKIE['linktrack'];
print 'The cookie ID is: '. $id;
}
Everything works fine if I type: mydomain.com/linktrack.php?id=1 into my browser. However when I use the rewritten URL: mydomain.com/go/1 no luck.
This is my .htaccess file:
Options +FollowSymLinks
RewriteEngine onRewriteRule ^go/(.*) linktrack.php?id=$1 [QSA]
Can anyone spot the problem here? Thanks in advance.
P.S. Please excuse the formatting. Can't get the code tags to work properly...not my day :(