Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass query string from page to page

Status
Not open for further replies.

920506

Programmer
Jun 13, 2003
201
US
Hi all,
We usually provide a link to our agents with their specific agentCode to our default page,
say With this id 12345, we can give credit to agents for their clients buying products on our site.
It doesn't matter what pages they are browsing on our web site, but when they click buy on our enrollment form,this value will be sent to server.
I am thinking of using javascript and cookie to record that code on html page and then in asp page, pick up the value from the cookie, is this good enough? any other better methods?
Any clue will help.
Thank you
Betty
 
I'm not sure I understand what your question is. Are you trying to pass the agent ID from page to page using the querystring? If so, what you have up above seems incorrect. Do you have relevant code that we can look at to help guide you (if need be)?

If you are looking to pass that value throughout the site, you could easily use either a cookie (provided they permit it on their browsers) or session variables (which also have limitations) in addition to your current method using the querystring variables.

Either way, it would help if you could clarify a little what you are asking.

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Hi,
The format of the link is basically tell us where the users come from. We don't have to pass querystring value from page to page(most of the pages are html, I cannot use session variable, only one page--buy page--care about what is the agentID). As long as the 12345 value can be caught up by .asp page. That's OK. Here is the code:

<!--
var str_help;
var pairs;
var asCookie;
var browser;
var pcnumber;
var sDateAndPath;
var nPCLength;

// ***NOTE no escaping has been done to any strings***
// The path of the cookie has been changed to '/'. The client may have a
// pre-existing cookie without a path. This cookie will not affect the
// following revised script.

// Get string from path
str_help = window.location.search;
pcnumber = str_help.substring(1,str_help.length);


// Check if affiliate ID is in the correct range

if ((pcnumber.length < 5) || (pcnumber.length > 7))
{
pcnumber = "";

// Cookie should contain only one valid name-value pair
asCookie = (document.cookie).split (";");

for (i = 0; i < asCookie.length; i++)
{
pairs = asCookie .split ("=");
if (pairs [0].indexOf ("id") != -1)
{
pcnumber = pairs [1];
}
}

if (pcnumber)
{
nPCLength = pcnumber.length;
}
else
{
nPCLength = 0;
}

// Check if ID is within the acceptable range
if (nPCLength < 5 || nPCLength > 7)
{
pcnumber = "12345"; // Default pcnumber
}
}


sDateAndPath = "path=/;expires=Wednesday, 01-Jan-2020 00:00:01 GMT";

//document.write("Final PCNUMBER:" + pcnumber + "<br>"); //foo

// Write cookie (if other parameters are added, above parsing will need to be altered)
document.cookie = "id=" + pcnumber + ";" + sDateAndPath;
 
How are they getting their Agent ID into your application? You can carry it in your querystring and then retrieve it from the one ASP page (I know, that's redundant - ;-)) without any problem. Perhaps I'm not understanding what you want to accomplish, but it seems like your method above may be more than you need (though it would probably also work).

------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
 
Personally, I'd set a session variable.... can't be "hacked" just by changing the address in the browser, and "disappears" when they close the browser.



Just my 2¢

"In order to start solving a problem, one must first identify its owner." --Me
--Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top