Changing a Variable to a constant.

Results 1 to 2 of 2

Thread: Changing a Variable to a constant.

  1. #1
    JB Guest

    Default Changing a Variable to a constant.

    HI Folks,<BR><BR>Here is what I would like to do but I do not know how.<BR><BR>My asp calls for a variable to get the reffering pages URL<BR><BR>Dim strReferringPage<BR>strReferringPage = Request.ServerVariables("HTTP_REFERER")<BR><BR>My script writes a few pages before it is done. As each new pages is written the variable "strReferringPage" changes with it.<BR><BR>Now I would like to create at the beginning, either a constant or a new variable that is the output of the Request.ServerVariables that would not change when my script goes to it&#039s second page. I would like to keep the original Refering URL throughout many pages.<BR><BR>This is what I want to do but I know is not allowed.<BR><BR>Dim strReferringPage<BR>strReferringPage = Request.ServerVariables("HTTP_REFERER")<BR>Const origReferringPage = strReferringPage<BR><BR>Could someone help me please?<BR><BR>Many Thanks,<BR><BR>JB<BR><BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Making a value *persistent*.

    You can&#039t change that variable to a constant, but what you *can* do (and quite easily) is to *remember* the value as long as you need to.<BR><BR>On the first page, you simply do:<BR><BR>&#060;%<BR>Dim strReferringPage<BR>strReferringPage = Request.ServerVariables("HTTP_REFERER")<BR>Session ("origReferringPage") = strReferringPage<BR>...<BR>%&#062;<BR><BR>and then, on subsequent pages, you do:<BR><BR>&#060;%<BR>Dim strReferringPage<BR>strReferringPage = Session("origReferringPage") <BR>...<BR>%&#062;<BR><BR>This is an ideal use of "Session variables" (a misnomer: they should be called "Session VALUES", but I&#039m not going to be able to change the world at this time)!<BR><BR>Go learn more about them in your favorite book or online reference(s).<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts