Thursday, August 22, 2013

Re: Saving geolocation data to session with timeout or better approach?

Set the Session configuration options in core.php. You can set the timeout there. On the client side, check the cookie to see if the coordinates are there. If not, regenerate them.

In fact, you could compare the coords from the cookie to the current location on each request.


On Sat, Aug 17, 2013 at 11:00 AM, MetZ <metz80@gmail.com> wrote:
Hi all.

I have a script that retrieves some location data from google api, and store the retrieved data in a Session (Location). All this is working just fine :) 
(if someone have a better way, better approach to store this data for my website visitors, let me know).

The data is saved to session (as of now), with an ajax call from the script.

example in controller for Geolocation.Lat:
if ($this->request->data['lat'] != "") {
$this->Session->write('Location.lat', $this->request->data['lat']);
}
(the other values are also stored similar; Location.long,Location.city and so on).

Now, I am wondering, how can I set a timeout on the session => Location.*

I want the visitors location data to be valid for, example 1 hour, before requesting new geolocation. 

Any suggestion how and where to store the data (the best approach) ??

Thanks for any input on this :)


-Tom

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: