Perspective IP address of device for a session

Is there a way to get the IP address of the device that has opened a session in Perspective? We have multiple plants across the country, and want to default the home page to the plant someone is opening up a Perspective session from, and if we could see their IP address, it would help us take a better guess at where they are. We have multiple plants in the eastern time zone, so the time zone alone isn’t enough. I didn’t see a session property, as you can only see the gateway address, but didn’t know if there was a hidden property or a command that could be run.

Just tested it, on your gateway page you can go to Status->Perspective Sessions and it will show you this information

blurred out my IP for reasons.

Thanks for the response, this is what I’m looking for, but I want to get this information in the Designer to be able to do scripting against it. For example, on session start i want to look at the IP and do something like

if session_ip == ‘192.168.XXX.XXX’:
plant = ‘New York’
if session_ip == ‘192.178.XXX.XXX’:
plant = ‘Charlotte’


Here’s my psuedo-code/plan to do this

Have a gateway tag called something like ‘getAllClientIPs’. Create a Client Tag Change on this tag, that runs
clientIp = - this returns the external IP. From here, you can have the client event script

  1. Add the IP to a dataset tag or
  2. Insert it into a DB column or
  3. send a message to the gateway with the information to now handle it in a gateway message handler script. However, if you have 100 running live clients, that gateway script will run 100 separate times, so you still need accumulate the data somewhere so that then you can run your logic on it.

Personally I’d probably choose the database route, and have a column like “session” to that keeps track of time you ran it. So the first time you click your gateway script to get IP’s, it inserts with session=1, and the next time you do it it will be session=2. Plus working with database inserts is cleaner and easier than dataset tags, plus you can just keep adding to it without performative issues to the gateway if your dataset tag got too large (and if you didn’t clear it). Not to mention anyone with access to the database could run analysis if they so chose.

Thanks for the response. In my designer on 8.0.15, the “getExternalIpAddress” doesn’t seem to work. I tried it on tag change scripts and gateway scripts. Your method makes sense, but I think I’ll see what Inductive has to say. If they have the IP info, as shown on the gateway status page, there has to be a way to get that in the Designer easily with a session property they could add. Thanks again for your response. is the closest thing you’re likely to get to an actual IP.

Retrieving the user’s actual IP in a browser session is not trivial and
requires fairly hacky workarounds, because browsers don’t like to share information like that:

Thanks for the response. I just figured since you’re able to display the IP on the gateway status page, then you know it, so it would be accessible.


1 Like

From within the session you could do this:

all_sessions = system.perspective.getSessionInfo()
for ses in all_sessions:
    # depending on where you're using this, you might need
    if =
        plant = ses.clientAddress

Perfect! That works great! Thanks for the help.

1 Like

Hi there,

I am trying to print the ‘all_sessions’ using print(‘all_session’) but it’s not working. Could you please tell me how can I print the contents of “all_session”



Hi Cmallonee,

Thanks for your quick response. I am writing a script on the button to show me the host ip whenever it is clicked, but I don’t see anything in the script console

Because you’re not using the code I provided. print only gets sent to the wrapper log I think. You need to specify that you are using system.perspective.print. Also, your indentation is incorrect. It looks like you copied and pasted code, but that often leads to faults in the indentation. Finally, make sure the Designer has the console open, or if you’re using a session you need to open the browser console. Executing this script will not display anything in the Script Console.

Just realized that “” is not equal to “”