I did make some changes to the plugin, which is perhaps why the error line wasn’t matching up.
Here is the latest error message I receive, which corresponds with the last line of the plugin:
Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxx/domains/mydomain.com/html/_sys/plugins/pi.radar.php:66) in /home/xxxxx/domains/mydomain.com/html/_sys/core/core.functions.php on line 726
.zip file attached.
Ah, silly mistake!
Ok, so now that I know cookies are the way to go, I want to make sure that I am going about capturing the “web_alias” value the best way.
I need to capture the “ID” value, which only exists in the referring URL:
http://www.mydomain.com/page.aspx?ID=web_alias
So, my question is, is there a better way to capture this value than what I am doing in the code below?
<?php
global $IN, $FNS;
$seconds = 60;
//Grab the referring URL, which includes ID=web_alias
$fs_refer = $IN->GBL('HTTP_REFERER', 'SERVER');
$fs_refer = explode("=", $fs_refer); //Is there a better way to capture the "ID" value from a referring URL?
$web_alias = $fs_refer[1]; //Sets the web_alias based on the referring URL
$FNS->set_cookie('web_alias', $web_alias, $seconds); //Finally, store the web_alias in a cookie
//This will grab the host, which I will use later on
$host_refer = parse_url($IN->GBL('HTTP_REFERER', 'SERVER'));
$host_refer = $host_refer['host'];
?>
Or is this only reliable way to rewrite links to include the “ID” value in the URL?
Cheers
Yeah the 60 seconds was just me putting something in there in my hurry to figure something that should work instead of the session cache.
I still don’t get why you are getting the ID value that way. Why not just the $IN->GBL(‘ID’) like one would normally do?
There is nothing stopping you from using the HTTP_REFERER thing to see where they are coming from. Just seems like a lot of steps to get one value when you can do it in one step.
Jamie
@Derek You’re not confused, that’s exactly right! I will adjust the cookie expiry time as well.
@Jamie No big deal, I thought I maybe wasn’t being clear, but yeah, the “ID” only exists in the referring URL. I just wasn’t sure if there was a better way to grab that value, but it appears not.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.