Forum Moderators: open

Message Too Old, No Replies

Passsing a SID to all pages in a site

Need help...

         

u4eas

2:18 pm on Oct 10, 2003 (gmt 0)

10+ Year Member



I have a third party that is sending us traffic with a SID attached to the url. So when someone clicks a link on the third parties site the url will look like this.

[mydomain.com...]

The PID is the session ID and the number increases by one each time its generated on the third parties site.

I need to track the PID/SID if the person clicks a different link on our site.

So if he goes to the home page the PID/SID passes along with the url.

[mydomain.com...]

So no matter where on the my site he goes the PID/SID is attached to that pages url

Thanks in advance!

defanjos

3:04 pm on Oct 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think setting a session variable would work, for example:

<%
if request("PID")<>"" then
session("PID") = request("PID")
end if
%>

Then you can use session("PID") anywhere you want - that way you don't need to append the PID to every url.

Setting a cookie might also work and does not use as many system resources.
I think if you have many users, it is not a good idea to set session variables, but someone else might know better.

WebJoe

3:12 pm on Oct 10, 2003 (gmt 0)

10+ Year Member



If I understand you correctly this could be a solution (along the line):

On your start-page (where the visitor enters) you have something like

<%
Session("SID") = Request.QueryString("PID")
%>

(of course you could re-define the sessions PID-value on every page), and then on every link you have

<A HREF="yourpage/index.asp?<%=Session("SID")%>">you link text</A>

Instead of a session you could set a cookie...

u4eas

4:03 pm on Oct 10, 2003 (gmt 0)

10+ Year Member




I think setting a session variable would work, for example:
<%
if request("PID")<>"" then
session("PID") = request("PID")
end if
%>

Then you can use session("PID") anywhere you want - that way you don't need to append the PID to every url.

Setting a cookie might also work and does not use as many system resources.
I think if you have many users, it is not a good idea to set session variables, but someone else might know better.

I added:

<%
if request("PID")<>"" then
session("PID") = request("PID")
end if
%>

To the top of everypage, but its not addeing the PID to the urls.

Is there should be something else added to actually add the pid to the url.

[edited by: u4eas at 4:08 pm (utc) on Oct. 10, 2003]

u4eas

4:06 pm on Oct 10, 2003 (gmt 0)

10+ Year Member




If I understand you correctly this could be a solution (along the line):
On your start-page (where the visitor enters) you have something like

<%
Session("SID") = Request.QueryString("PID")
%>

(of course you could re-define the sessions PID-value on every page), and then on every link you have

<A HREF="yourpage/index.asp?<%=Session("SID")%>">you link text</A>

This seems to work, but i dont want to change every link on my site:(

defanjos

4:50 pm on Oct 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



u4eas,

Why do you need the PID in every URL?

If you really need it in every URL, you need to change them all.

If you just want to keep track of the PID no matter where the visitor goes, all you have to do id keep it as a session variable and then read it when you need it - for example, to give credit to an affiliate, etc.

u4eas

5:36 pm on Oct 10, 2003 (gmt 0)

10+ Year Member



I see..

The reason is that there is a form on my site that needs to have the PID but its seems I cant keep the pid when I navigate to another page and then go back to the form.

I just added the code to each link to add the PID that way I know it works 100% of the time.

Just wish I knew how to do it without adding the code to each link.

Thanks for you help :)

defanjos

6:06 pm on Oct 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just wish I knew how to do it without adding the code to each link.

I don't know your form code, but you have to use something like this to call the URL PID <%=request("PID")%>, instead of it, use <%= session("PID")%>. Of course, you have to set the session variable first, like I showed you on my first post.

WebJoe

9:37 pm on Oct 10, 2003 (gmt 0)

10+ Year Member



If it's only the form where you need the PID then just "ask" for it there by having a
<% =Session("PID")%>

Once stored in your session variable with the code mentioned by defanjos, aöways availabe until the visitor leaves your site and therefore end the session.

u4eas

8:17 pm on Oct 13, 2003 (gmt 0)

10+ Year Member



Thanks I will try that =)

u4eas

8:22 pm on Oct 14, 2003 (gmt 0)

10+ Year Member



Worked like a charm thanks =)

Converted all my links back to just .asp and called the session pid on the form.

WebJoe

10:35 pm on Oct 14, 2003 (gmt 0)

10+ Year Member



gr8, Glad we could help