# How to handle session with external input?

**URL:** <https://www.ruby-forum.com/t/how-to-handle-session-with-external-input/205895>\
**Category:** Rails\
**Created:** [April 18, 2011, 11:50am UTC](https://www.ruby-forum.com/t/how-to-handle-session-with-external-input/205895 "2011-04-18T11:50:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 18, 2011, 11:50am UTC](https://www.ruby-forum.com/t/how-to-handle-session-with-external-input/205895/1 "2011-04-18T11:50:23Z")

</div>

Hi,

I hope I chose the right title for the question. I am doing a time  
tracking app for our intranet. Because the people tend to forget to  
save their hours, we made a small desktop app with adobe air that pops  
up where you can enter your hours, the hours should be posted to the  
hours controller of the rails app.

When we post the data to /hours/new we get redirected to the login  
page, because we are not logged in.  
Question is can a session exist outside of the application, or does  
session return anything that we could send with each post data to  
confirm that the user is logged in?

which route you guys would go in order to solve this problem?  
many thanks in advance…

frank blizzard

---

<div class="post-metadata">

**Author:** ![frankblizzard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e47774/32.png) [@frankblizzard](https://www.ruby-forum.com/u/frankblizzard)\
**Post date:** [April 19, 2011, 11:21pm UTC](https://www.ruby-forum.com/t/how-to-handle-session-with-external-input/205895/2 "2011-04-19T23:21:08Z")

</div>

Thanks Bryan,

sure this wouldn’t be a problem.  
But isn’t a session connected to the browser in some way.  
I think I dont understand the whole session, authenticity, forgery  
topic in rails yet.  
You think I can login the user once from the Air app and after the  
server will accept post requests, or do I need to pass back the  
session data from the server (session\_id, token) and send it then with  
each request back from the Air app?

Thomas

---

<div class="post-metadata">

**Author:** ![frankblizzard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e47774/32.png) [@frankblizzard](https://www.ruby-forum.com/u/frankblizzard)\
**Post date:** [April 18, 2011, 3:36pm UTC](https://www.ruby-forum.com/t/how-to-handle-session-with-external-input/205895/3 "2011-04-18T15:36:02Z")

</div>

On Mon, Apr 18, 2011 at 4:48 AM, frankblizzard  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Question is can a session exist outside of the application, or does  
> session return anything that we could send with each post data to  
> confirm that the user is logged in?
> 
> which route you guys would go in order to solve this problem?  
> many thanks in advance..

I would suggest coding your Adobe Air application to login into your  
rails  
app before trying to add the hours. If you have the users  
login/password,  
whether provided by the user or stored by them in your Air app, then it  
should not be too much of an issue to send them over to your login  
controller and log the user in.

B.

---

<div class="post-metadata">

**Author:** ![frankblizzard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e47774/32.png) [@frankblizzard](https://www.ruby-forum.com/u/frankblizzard)\
**Post date:** [April 20, 2011, 3:28pm UTC](https://www.ruby-forum.com/t/how-to-handle-session-with-external-input/205895/4 "2011-04-20T15:28:44Z")

</div>

On Tue, Apr 19, 2011 at 4:19 PM, frankblizzard  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> Thanks Bryan,
> 
> sure this wouldn’t be a problem.  
> But isn’t a session connected to the browser in some way.  
> I think I dont understand the whole session, authenticity, forgery  
> topic in rails yet.

It uses cookies to store the session information. You would need to pass  
that cookie info back on requests. You can learn more about it here:

> **[Securing Rails Applications — Ruby on Rails Guides](https://guides.rubyonrails.org/security.html)**
>
> This guide describes common security problems in web applications and how to avoid them with Rails.After reading this guide, you will know: How to use the built-in authentication generator. All countermeasures that are highlighted. The concept of...

> You think I can login the user once from the Air app and after the  
> server will accept post requests, or do I need to pass back the  
> session data from the server (session\_id, token) and send it then with  
> each request back from the Air app?

You may want to look into the plugin WebORB. It allows for flex  
applications  
to connect to Rails and us your classes like web services.

> **[FlowRunner | Orchestration as a Service](https://flowrunner.ai/)**
>
> AI agents that run your operations and ask your team when they hit an exception. No-code. Audit-ready. Human-in-the-loop.

You also definitely want to check out the site [flexonrails.com](http://flexonrails.com). They  
have a  
series of Air apps that they connected to Rails for a demo at  
RailsCon2008  
and all the source is on their site.

> **[Flex on Rails - Powering AIR+Flex applications with Rails](http://flexonrails.com/)**

B.
