views:

18

answers:

0

I'm running a geo-location-javascript (http://code.google.com/p/geo-location-javascript/) to find and set the users latitude and longitude to a cookie.

I'm running this to try and update the cookie on each page load.

<script> 

        function del_cookie(name) { 
            document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
        }

        if(geo_position_js.init()){
            geo_position_js.getCurrentPosition(success,error);
        }
        else{
            alert("Functionality not available");
        }

        function success(p)
        {

            del_cookie('user_latitude');
            del_cookie('user_longitude');
            document.cookie = "user_latitude=" + p.coords.latitude;
            document.cookie = "user_longitude=" + p.coords.longitude;
            $('body').load('pool.php');

        }


        function error(p)
        {
            alert('error='+p.message);
            $('body').load('error.html');
        }       

</script> 

But it doesn't seem to update on each page load, at least for the iPhone. Any ideas? or maybe a more efficient way to do this?

I want to be able to get up to date location information of a mobile user.