Zen Cart Logo
Forums / Code Collaboration / Recommended method to capture GET parameters?

Recommended method to capture GET parameters?

Views: 3,068

Results 1 to 7 of 7
17 Jan 2013, 21:03
#1
lsb57 avatar

lsb57

New Zenner

Join Date:
Oct 2012
Posts:
9
Plugin Contributions:
0

Recommended method to capture GET parameters?

All,

What's the best way to capture a GET parameter passed when the main page is invoked similarly to http://site.here/index.php?main_page=index&a_parameter=some_value

One way is to add a section to application_top.php, like this:

if ( isset($_GET["a_parameter"]) )
{
$_SESSION["a_parameter"] = $_GET["a_parameter"];
setcookie("a_parameter", $_GET["a_parameter"], time() + 606024*3, "/");

}

While this works, it makes upgrades more complicated. Is there a better way, maybe in the form of attaching to a notification message? If I can keep the code outside of the standard application_top.php, upgrade would be simpler.

Thanks!

17 Jan 2013, 21:09
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Recommended method to capture GET parameters?

Lets back up WAY BACK TO THE BEGINNING.

What are these GET parameters for anyway? What's the bigger picture business issue you're trying to address?
What code are these GET parameters coming from?
What exactly do yo mean by "method to capture"? Why are you trying to "capture"? What are you doing with this information? Why are you putting it into a session variable?
It sounds like you're trying to alter custom code ... but haven't said what this custom code does.

17 Jan 2013, 21:50
#3
lsb57 avatar

lsb57

New Zenner

Join Date:
Oct 2012
Posts:
9
Plugin Contributions:
0

Re: Recommended method to capture GET parameters?

It's affiliate related. I want to know which site referred my store. So the referring site will use a parameter in their link to my site - I need to capture that so I can track what orders are associated with the referral.

17 Jan 2013, 22:33
#6
lsb57 avatar

lsb57

New Zenner

Join Date:
Oct 2012
Posts:
9
Plugin Contributions:
0

Re: Recommended method to capture GET parameters?

On a second thought - is the global $db available at this stage? Say I want to have a configuration group for the autoloader?

17 Jan 2013, 22:43
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Recommended method to capture GET parameters?

No .