Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6780249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:29:01+00:00 2026-05-26T16:29:01+00:00

I have RESTful API written on RoR 3. I have to make my application

  • 0

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 tried to use session :off and reset_session but it does not make any sense.
I am using devise as authentication framework.

Here is my ApplicationController

class ApplicationController < ActionController::Base
  before_filter :reset_session #, :unless => :session_required?
  session :off #, :unless => :session_required?

  skip_before_filter :verify_authenticity_token
  before_filter :access_control_headers!

  def options
    render :text => ""
  end

  private
  def access_control_headers!
    response.headers["Access-Control-Allow-Origin"] = "*"
    response.headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, DELETE, OPTIONS"
    response.headers["Access-Control-Allow-Credentials"] = "true"
    response.headers["Access-Control-Allow-Headers"] = "Content-type"
  end

  def session_required?
    !(params[:format] == 'xml' or params[:format] == 'json')
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:29:01+00:00Added an answer on May 26, 2026 at 4:29 pm

    As is mentioned in a comment on John’s answer, clearing the session will not prevent the session cookie from being sent. If you wish to totally remove the cookie from being sent, you have to use Rack middleware.

    class CookieFilter
      def initialize(app)
        @app = app
      end
    
      def call(env)
        status, headers, body = @app.call(env)
    
        # use only one of the next two lines
    
        # this will remove ALL cookies from the response
        headers.delete 'Set-Cookie'
        # this will remove just your session cookie
        Rack::Utils.delete_cookie_header!(headers, '_app-name_session')
    
        [status, headers, body]
      end
    end
    

    Use it by creating an initializer with the following body:

    Rails.application.config.middleware.insert_before ::ActionDispatch::Cookies, ::CookieFilter
    

    To prevent the cookie filter to end up in application stack traces, which can be utterly confusing at times, you may want to silence it in the backtrace (Assuming you put it in lib/cookie_filter.rb):

    Rails.backtrace_cleaner.add_silencer { |line| line.start_with? "lib/cookie_filter.rb" }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a RESTful API set up and working with CakePHP using mapResources() and
I have an API module in my application which is a RESTful API -
I have been trying to wrap my head around creating a RESTFul API using
I have a RESTful API written on RubyOnRails(restfulie gem). What is the best way
I am trying to make a RESTful api and have some function which needs
I am trying to set up an internal RESTful API using NodeJS that communicates
We have restful api over HTTP. Amongst other clients we have also mobile-device clients
Currently we have a a RESTful API using CXF 2.4.2. In one of my
I have a RESTful API containing a URI of /UserService/Register. /UserService/Register takes an XML
I am new to Restful concept and have to design a simple API for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.