Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
8 Odgovori
8383 Prikazi

Am trying to track the visitor ip address ,but am failed to  implement it..please help me...Urgent.

Avatar
Opusti
Best Answer

Hi,

You can try the below code:

if "HTTP_X_FORWARDED_FOR" in request.httprequest.environ:
    # Virtual host
    ip = request.httprequest.environ["HTTP_X_FORWARDED_FOR"]
elif "HTTP_HOST" in request.httprequest.environ:
    # Non-virtualhost
    ip = request.httprequest.environ["REMOTE_ADDR"]


Hope this could helps

Avatar
Opusti
Avtor

I got Exception 'object unbound'

Can you paste your code ..

Avtor

from openerp.http import request

def git_ip():

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

Avtor

from openerp.http import request

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

Avtor

from openerp.http import request

def get_ip():

ipnew = request.httprequest.environ['REMOTE_ADDR']

return ipnew

May be you're missing @http.rout decorator. Btw from where you're calling your method ?

Related Posts Odgovori Prikazi Aktivnost
7
jul. 24
27690
10
jun. 21
40322
1
mar. 18
9411
1
mar. 15
6287
0
mar. 15
4068