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 4027766
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:08:15+00:00 2026-05-20T11:08:15+00:00

I have a REST API in Rails 3 being accessed sometimes from an AIR

  • 0

I have a REST API in Rails 3 being accessed sometimes from an AIR application and sometimes from the browser.

I think this is a Rails 3 problem but it might be a Flex/AIR problem.

The Rails app uses omniauth for authentication, cancan for authorization, and active_record_store. I use the session model to store the identity of the user.

(There is a reason I’m not using cookie sessions, having to do with AIR for Android, OAuth, and StageWebView.)

I’m using Charles to monitor HTTP traffic.

Most requests work fine. The browser (or the AIR client) sends the session ID to the server using the Cookie http header, like this:

_session_id=950dee7eca6732aa62b5f91876f66d15

And Rails finds the session, figures out who the user is, and does its thing.

But under certain circumstances, Rails generates a new session before sending the response. It adds a session to the sessions table, and returns a Set-Cookie header to the client with a new session ID. Like this:

_session_id=e1489a6b610c0a1d13cec1454228ae47; path=/; HttpOnly

The circumstances under which this happens are:

  • The request comes from the AIR client
  • The request is a POST

This is obviously a problem, because on subsequent requests, Rails can’t find the user information. It created a new session without that information.

So I’m looking at the HTTP headers for the POST request. Here’s a copy/paste from Charles; I inserted the colon after the header name to make it readable.

Host: localhost.seti.hg94.com:3000
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/531.9 (KHTML, like Gecko) AdobeAIR/2.6
Referer: app:/AndroidApplication.swf
X-Flash-Version: 10,2,152,22
Accept: */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Cookie: _session_id=950dee7eca6732aa62b5f91876f66d15
Content-Length: 84
Connection: keep-alive

Does anyone have any insight into why Rails would generate a new session under those circumstances? It seems to be happening after my controller code executes, since I have the correct session information in the controller.

I’m busy trying to isolate the problem further, control the headers from within AIR, and so on. I’ve been working on this bug for almost a week. So any insight or suggestions from the community would be greatly appreciated.

  • 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-20T11:08:16+00:00Added an answer on May 20, 2026 at 11:08 am

    Only a guess, but it seems like you’re not bringing across the CSRF token that Rails generates for all POST-based requests:

    http://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a REST API that must be authenticated via BasicAuth, but later
I am using salesforce rest api to access the salesforce account from my rails
I have a strange behavior of Rails 3.0.10. Got this application controller: app/controllers/application_controller.rb require
I have read many about REST api in php articles. but I still get
I have a web application that consists of Website and REST API. Should I
We are trying to implement a REST API for an application we have now.
I guess this more of a design question, but I currently have a REST
I have a REST API that I am trying to access using Rails 3.0.1
I am developing a REST API, and have found a very interesting problem. When
I am developing a REST API layer for my application using Zend_Rest_Controller. I have

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.