I need to change a cookie from "Session" type to "Persistent" type. Moreover I need to have it working together with "omniauth-facebook". In the example below everything is working well but when I use omniauth the cookie is not set at all. This is the test code I wrote:
require 'rubygems' require 'sinatra' require 'encrypted_cookie' require 'omniauth-facebook' use Rack::Session::EncryptedCookie, :secret => "fdstopitot9dasdsdasjm4kmt0èu54cmjff83d2'ìel.4j9c" use OmniAuth::Builder do provider :facebook, '290594154312564','a26bcf9d7e254db82566f31c9d72c94e' end get "/" do "persistent | session | /auth/facebook" end get "/persistent" do response.set_cookie 'test', {:value=> "persistent", :max_age => 2592000.to_s} redirect "/" end get "/session" do response.set_cookie 'test', {:value=> "session"} redirect "/" end get '/auth/:provider/callback' do response.set_cookie 'test', {:value=> "facebook_callback"} redirect "/" end
Clicking on /session
or /persistent
you can see the cookie changing accordingly (in Chrome you can check cookies with F12 > Resources > Cookies > localhost).
Clicking instead on /auth/facebook
the cookie is not set at all.
The response header seems ok (in Chrome you can see the http response header with F12 > Network > header). I only tested it with Chrome.
HTTP/1.1 302 Moved Temporarily X-Frame-Options: SAMEORIGIN Location: http://localhost:4567/ X-XSS-Protection: 1; mode=block Content-Type: text/html;charset=utf-8 Content-Length: 0 Set-Cookie: test=facebook_callback Set-Cookie: rack.session=X8U8kupLYzIurjMS4pSCQfF%2BzPpjQhJMqyMd84o8BQdQLwmhagL1UkZ4oi7%2F%0A9bEN%2B0FZDDUAeQD%2BRizczwvepQi%2FbcMwaAjpkFcXhiWuJPQ%3D%0A; path=/ X-Content-Type-Options: nosniff Connection: keep-alive Server: thin 1.5.1 codename Straight Razor
Any clue?