PDA

View Full Version : Retain session when launching app from home screen



somanyfish
8 Dec 2010, 2:10 PM
I am attempting implement log in functionality similar to the Vimeo app (http://vimeo.com/awards/m). The home page of this app writes a javascript variable into the head:


var vimeo = { domain: '.vimeo.com', vimeo_url: 'vimeo.com', loggedIn: true, token: 'fe...4821', user: "Joe Smith", portrait: 'http://a.vimeocdn.com/portraits/defaults/d.75.jpg', images: { tabletStartup: "http://a.vimeocdn.com/images/awards/splash_768.png", phoneStartup: "http://a.vimeocdn.com/images/awards/splash_320.png", retinaStartup: "http://a.vimeocdn.com/images/awards/splash_640.png", icon: "http://a.vimeocdn.com/images/awards/apple_touch_icon.png", logo: "http://a.vimeocdn.com/images/awards/logo_smaller.png", iacwall: "http://a.vimeocdn.com/images/awards/iac-wall.jpg", mapMarkerVimeo: "http://a.vimeocdn.com/images/awards/map_marker_vimeo.png", mapMarkerDrivein: "http://a.vimeocdn.com/images/awards/map_marker_drivein.png", mapMarkerSva: "http://a.vimeocdn.com/images/awards/map_marker_sva.png" } };

Then, the mobile.js script checks the value of the vimeo.loggedIn to determine if the user should be sent through the log in process. How does the server know to fill this vimeo variable? On the iPhone browser, it retains my logged in status when I wipe the cookies, on Safari on my desktop, running as iPhone 4.1, wiping cookies loses the logged in status.

My server side code is a Rails app and I observe this behavior: when I am logged in to my app and open it up in a new Safari window, the app can read the cookies in the standard fashion. However, when I launch the app from my home screen icon, log in, then launch it again from the home screen icon, the Rails gets an empty cookies hash.

The Vimeo app is able to retain the information when launching from the home screen and I'd love to know how.

Any help much appreciated!