Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-11-2006, 05:05 PM   PM User | #1
thiazi
New Coder

 
Join Date: Aug 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
thiazi is an unknown quantity at this point
Session Cookies

I'm new to using session cookies and need just a bit of help. On the introduction page to my project, I'm setting:

Code:
<%@ Language=VBScript %>
<% 

response.cookies("user")="authenticated" 

%>
Then, on subsequent pages, I'm checking for the cookie, and redirecting if it's not there:

<%@ Language=VBScript %>
<%

If NOT request.cookies("user") = "authenticated" Then
response.redirect "http://somepage"
End If


%>

What I need to do is incorporate an ignore element (by user-agent or IP) into where it checks for the cookie. For instance, if a user has an IP of 127.0.0.1, it ignores whether they have the cookie or not and lets them view the page.

The reason I'm doing this is I have a search engine that's crawling the site and it doesn't always go through the front page - therefore, it's getting redirected on most of the pages it sees. So what I'd like to do is have the script see that user-agent or IP, then ignore the cookie requirement.

Is that possible?
thiazi is offline   Reply With Quote
Old 12-12-2006, 02:36 PM   PM User | #2
thiazi
New Coder

 
Join Date: Aug 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
thiazi is an unknown quantity at this point
Anyone?
thiazi is offline   Reply With Quote
Old 12-12-2006, 02:46 PM   PM User | #3
EricaStar
New Coder

 
Join Date: Nov 2006
Posts: 47
Thanks: 2
Thanked 1 Time in 1 Post
EricaStar is an unknown quantity at this point
I don't know if it's possible in regular ASP. I assume it is. I just don't know how. But in .net to get the IP address:

Dim TheIPAddress As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)

Dim IPaddress As String = (TheIPAddress.AddressList.GetValue(0).ToString)

Then you would just have to check IPaddress. If it is a good one then you would authenticate them through code.

I hope this helps.
EricaStar is offline   Reply With Quote
Old 12-12-2006, 02:56 PM   PM User | #4
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Not sure I understand completely, but you can check out the http_referer:
http://www.w3schools.com/asp/coll_servervariables.asp

Let us know how it works out
Good luck;
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 12-12-2006, 03:04 PM   PM User | #5
thiazi
New Coder

 
Join Date: Aug 2006
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
thiazi is an unknown quantity at this point
Thanks for that link. So I need to: Request.ServerVariables (HTTP_USER_AGENT). Then I need to take that result and compare it with the user-agent I'm expecting (the search crawler). If they match, ignore the redirect and cookie requirement and let the user view the page. If they don't match, follow the routine as normal and redirect if the cookie isn't present. How would I write that?
thiazi is offline   Reply With Quote
Old 12-12-2006, 04:27 PM   PM User | #6
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,472
Thanks: 4
Thanked 40 Times in 40 Posts
Brandoe85 will become famous soon enough
Write it just as your other if statement when you redirect, cept this time use the user agent or whatever you are comparing with.

I think you can get it, if not let us know
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:43 PM.


Advertisement
Log in to turn off these ads.