Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy cookie doesn't work using Sinatra and Omniauth?
    primarykey
    data
    text
    <p>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:</p> <pre> 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 </pre> <p>Clicking on <code>/session</code> or <code>/persistent</code> you can see the cookie changing accordingly (in Chrome you can check cookies with F12 > Resources > Cookies > localhost).</p> <p>Clicking instead on <code>/auth/facebook</code> the cookie is not set at all.</p> <p>The response header seems ok (in Chrome you can see the http response header with F12 > Network > header). I only tested it with Chrome.</p> <pre> 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 </pre> <p>Any clue?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload