Print Page | Close Window

IP problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=487
Printed Date: 28 March 2026 at 10:23pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: IP problem
Posted By: skyworld
Subject: IP problem
Date Posted: 24 February 2003 at 5:02pm

On my site i want the ip for reference but i have a problem...

i am trying to set the ip as a cookie and it comes out as:

"ip=65%2E32%2E102%2E123"

My code is...

'-------------------------------------------------------

<%
'GET IP
Dim ipaddress
ipaddress = request.servervariables("http_x_for")
if ipaddress <> "" then
theip = ipaddress
else
theip = request.servervariables("remote_addr")
end if
if request.cookies("ip") = "" then
response.cookies("ip") = theip
response.cookies("ip").expires = date() + 365
'End of get ip!
else
end if
%>
'-------------------------------

now when i preview it in browser if i dont include theip step it shows the ip and if i use ipaddress it doesnt... I tried setting it as a cookie and it tells me that the headers are already written to... Where did i go wrong?




Replies:
Posted By: nittystone
Date Posted: 24 February 2003 at 8:48pm

i don't your problem

i use xml document to save client ip

in session_start

objdom.load(application("manager_xml"))
 set online=objdom.selectSingleNode("//main/online")
 'set parts=objdom.selectSingleNode("//main/shop").childNodes
 
 set NewNode=objdom.createElement("user")
 
 set NewAttr=objdom.createAttribute("id")
 NewAttr.NodeValue=session("id")
 NewNode.SetAttributeNode NewAttr
  
 set NewAttr=objdom.createAttribute("time")
 NewAttr.NodeValue=date() & " " & time()
 NewNode.SetAttributeNode NewAttr
 
 set NewAttr=objdom.createAttribute("id")
 NewAttr.NodeValue=session("id")
 NewNode.SetAttributeNode NewAttr
 
 set NewAttr=objdom.createAttribute("ip")
 NewAttr.NodeValue=request.ServerVariables("REMOTE_ADDR")
 NewNode.SetAttributeNode NewAttr
 
 set NewAttr=objdom.createAttribute("gotime")
 NewAttr.NodeValue=""
 NewNode.SetAttributeNode NewAttr
 
 set NewAttr=objdom.createAttribute("username")
 NewAttr.NodeValue=session("name")
 NewNode.SetAttributeNode NewAttr
 online.appendChild NewNode
 objdom.save(application("manager_xml"))



-------------
i'm fly to be near you to be free

i'm a chinese
i want study english in here
thanks every obdy


Posted By: skyworld
Date Posted: 25 February 2003 at 9:08am
hmm... i might try that then


Posted By: MorningZ
Date Posted: 25 February 2003 at 12:36pm
I'm still trying to figure out why you are saving the IP on the client's cookie..

if you need their IP, simply use
Request.ServerVariables("REMOTE_HOST")

why set the cookie when the value is the exact same?

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: skyworld
Date Posted: 25 February 2003 at 4:19pm
ok good point


Posted By: skyworld
Date Posted: 25 February 2003 at 4:20pm
i wanted the ip for themes origionally because i was going to use it with a database but changed my mind



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net