# Backgroundrb and authorization/sessions

**URL:** <https://www.ruby-forum.com/t/backgroundrb-and-authorization-sessions/91557>\
**Category:** Rails\
**Created:** [April 10, 2007, 1:12pm UTC](https://www.ruby-forum.com/t/backgroundrb-and-authorization-sessions/91557 "2007-04-10T13:12:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joergd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@joergd](https://www.ruby-forum.com/u/joergd)\
**Post date:** [April 10, 2007, 1:12pm UTC](https://www.ruby-forum.com/t/backgroundrb-and-authorization-sessions/91557/1 "2007-04-10T13:12:00Z")

</div>

Hi,

I have a backgroundrb task that performs a long running task initiated  
through a website. The website also uses authorization to log users on,  
and to record/audit who changes which record.

What is the easiest way for my background tasks to pick up that  
information from the session of the logged in user … or is this  
something I will need to pass into the do\_work method?

Thanks  
Joerg

---

<div class="post-metadata">

**Author:** ![joergd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@joergd](https://www.ruby-forum.com/u/joergd)\
**Post date:** [April 10, 2007, 1:44pm UTC](https://www.ruby-forum.com/t/backgroundrb-and-authorization-sessions/91557/2 "2007-04-10T13:44:26Z")

</div>

Joerg D. wrote:

> I have a backgroundrb task that performs a long running task initiated  
> through a website. The website also uses authorization to log users on,  
> and to record/audit who changes which record.
> 
> What is the easiest way for my background tasks to pick up that  
> information from the session of the logged in user … or is this  
> something I will need to pass into the do\_work method?

Pass the ID of the user into the worker’s construction parameters, and  
let  
the background task pick everything else up from the database.

Your question suggests you might be abusing the session[] hash. Only use  
it  
for data that belong only to one series of pages in one web browser.  
Don’t  
use it to avoid sticking important information into the database.

–  
Phlip  
["Pigleg too?", week 1](http://flea.sourceforge.net/PiglegToo_1.html)
