lundi 28 mars 2016

How to fetch users browsing location and store in cookie in rails

i want to store user selected location as cookie. if location is not selected automatically it should fetch users browsing location and store as a cookie value. How to do so?

i have done the code like this when user selects a location, location is storing as cookie now by this code.

@location = Location.find(location).name if location.present? cookies[:location_id] = { :value => @location, :expires => Time.now + 3600}

But i don't have any idea to fetch users browsing location automatically and store in cookie.

Please help me to do this.

Any help is appreciatable.

Aucun commentaire:

Enregistrer un commentaire