Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Javascript know your IP? [duplicate]

Tags:

javascript

php

ip

Possible Duplicate:
Get Client IP using just Javascript?

I know PhP can know your IP from <?php echo $_SERVER['REMOTE_ADDR']; ?>

How can javascript do so?

Or is it true that because javascript is client side it doesn't know the IP of the computer?

like image 227
user4951 Avatar asked Jul 19 '11 10:07

user4951


1 Answers

If the file containing your JS code is parsed by PHP, you should be able to inject the IP-address into the JS code by PHP.

<script type="text/javascript">
 var ipaddress = "<?php echo $_SERVER['REMOTE_ADDR']; ?>";
</script>
like image 147
Martin Avatar answered Oct 12 '22 21:10

Martin