HTTP_REFERRER

This is a discussion on "HTTP_REFERRER" within the Classic ASP section. This forum, and the thread "HTTP_REFERRER are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 16th, 2003, 14:20
Junior Member
Join Date: Aug 2003
Location: USA
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
HTTP_REFERRER

I've got what should be a simple problem that is beyond me. A page that requires login calls the login page and sends the URL of that page, so the login page will return to the requesting page. The URL is being sent to the login page. If I do <%=response.write XXX%> on the form of the login page, it shows "/cart.asp", which is correct. But, the login page will not return to "/cart.asp", it goes to default.asp.

Is there some little something in the syntax that is not quite right?

Thanks for any all assistance.

Ernest

<%
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "Cache-Control", "no-cache"
Dim HTTP_REFERRER, UserObject
Status = "Please log in."
HTTP_REFERRER = Request.querystring("HTTP_REFERRER")
If Request.Form("username") <> "" Then
If Login Then

' MODIFY THE SESSION VARIABLE AS REQUIRED

Session("UID") = UserObject.Item("EmailUserId")
Set Session("UID") = UserObject

If HTTP_REFERRER = "" Then
Response.Redirect "../default.asp"
Else
Response.Redirect 'HTTP_REFERRER'
End If
Else
Response.Redirect "loginfailed.asp"
End If
End If

Function Login
Dim conn, rs, sql, dbFIle
dbFile = "EmailUser"
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ="Provider=sqloledb;Data Source=xxxxx,1433;Network Library=DBMSSOCN;Initial Catalog=xxxxx;User Id=xxxxx;Password=xxxxxx;"

Set rs = Server.CreateObject("ADODB.Recordset")
sql = "SELECT * FROM EmailUser WHERE (NOT (U_Access = 0)) And U_ID = '" & Request.Form("Username") & "' AND U_Password = '" & Request.Form("Password")& "'"
rs.Open sql, conn, 3, 3
If Not rs.EOF Then
Set UserObject = CreateObject("Scripting.Dictionary")
For each field in rs.Fields
UserObject.Add field.name, field.value
Next
Login = True
Else
Login = False
End If
rs.Close
set rs = nothing
conn.Close
set conn = nothing
End Function
%>

  #2 (permalink)  
Old Oct 16th, 2003, 14:56
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
<s>on Line 5 use:

Request.servervariables("HTTP_REFERRER")

instead of:

Request.querystring("HTTP_REFERRER")</s>

Oh wait I see what your doing....
Does the querystring look like this:
login.asp?HTTP_REFERRER=cart.asp
  #3 (permalink)  
Old Oct 16th, 2003, 15:34
Junior Member
Join Date: Aug 2003
Location: USA
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the reply. That address bar on the login page shows: http://southeastplaza.com/user/login...RRER=/cart.asp.

But I'm still being redirected to the default page. The login page
is two folders down in the directory tree. If I set response.redirect to "/cart.asp" it returns, so I'm thinking that the directory structure is not the problem.

I have changed the line: Response.Redirect 'HTTP_REFERRER' to double quotes and no quotes.

Thanks
Ernest
  #4 (permalink)  
Old Oct 16th, 2003, 17:00
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
You're going to have problems passing a URL via Querystrings.

Since you are already using Sessions, why not store the referring page as a session variable during the login check?
  #5 (permalink)  
Old Oct 20th, 2003, 13:26
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
you have spelt referer wrong, its "referer", not "referrer".
  #6 (permalink)  
Old Nov 11th, 2003, 15:46
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,951
Blog Entries: 7
Thanks: 7
Thanked 3 Times in 3 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
I just spotted this thread.... so here goes:-

to link to the login page use something like this:-
Code: Select all
Response.write "<a href=""login.asp?Referrer=" & server.urlencode(request.servervariables("Script_Name"))
If request.querystring <> "" then response.write "?" & server.urlencode(request.querystring)
Response.write """>Login</a>"
on the login page, you can then happily set URL=request.querystring("referrer") and then response.redirect URL

Hope this helps:-
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Closed Thread

Tags
http_referrer

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 21:52.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43