Rails 3 disabling session cookies

前端 未结 10 1885
梦如初夏
梦如初夏 2020-11-30 00:06

I have RESTful API written on RoR 3. I have to make my application not to send \"Set-Cookie header\" (clients are authorizing using auth_token parameter).

I have tri

10条回答
  •  有刺的猬
    2020-11-30 00:46

    Another solution: In the controller you want to avoid cookies, add this:

    after_filter :skip_set_cookies_header
    
    def skip_set_cookies_header
      request.session_options = {}
    end
    

    If you have a set of api controllers, set this in an api_controller class and let your other controllers inherit the api_controller.

    This skips setting Set-Cookie header since the session opts is empty.

提交回复
热议问题