# Working with sessions in beast forum

**URL:** <https://www.ruby-forum.com/t/working-with-sessions-in-beast-forum/147307>\
**Category:** Rails\
**Created:** [August 30, 2008, 7:24pm UTC](https://www.ruby-forum.com/t/working-with-sessions-in-beast-forum/147307 "2008-08-30T19:24:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GearSSS\_id\_OSCealla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@GearSSS\_id\_OSCealla](https://www.ruby-forum.com/u/GearSSS_id_OSCealla)\
**Post date:** [August 30, 2008, 7:24pm UTC](https://www.ruby-forum.com/t/working-with-sessions-in-beast-forum/147307/1 "2008-08-30T19:24:28Z")

</div>

Hey,

I’m designing an app which displays the events near a user in RoR. I’m  
using the beat forum to facilitate user management/sessions/etc. I’ve  
edited the sessions table in the Beast database to contain a  
“session\_location” value and what I’d like to do is to set this to the  
users location when they log in. This would allow them to change their  
location for a session whilst not changing the value in their  
settings.

I know that I have to set this value when a session is created but I’m  
baffled about how (and where exactly) I have to do it. The following  
code is used when creating a session:

class SessionsController \< ApplicationController  
def create  
if using\_open\_id?  
cookies[:use\_open\_id] = {:value =\> ‘1’, :expires =\>  
1.year.from\_now.utc}  
open\_id\_authentication  
else  
cookies[:use\_open\_id] = {:value =\> ‘0’, :expires =\>  
1.year.ago.utc}  
password\_authentication params[:login], params[:password]  
end  
end

protected  
def open\_id\_authentication  
authenticate\_with\_open\_id params[:openid\_url] do |result,  
openid\_url|  
if result.successful?  
if self.current\_user = User.find\_by\_openid\_url(openid\_url)  
successful\_login  
else  
failed\_login “Sorry, no user by the identity URL  
{openid\_url} exists”[:openid\_no\_user\_message, openid\_url.inspect]  
end  
else  
failed\_login result.message  
end  
end  
end

```
def password_authentication(name, password)
  if self.current_user = User.authenticate(name, password)
    successful_login
  else
    failed_login "Invalid login or password, try again

```

please."[:invalid\_login\_message]  
end  
end

```
def successful_login
  cookies[:login_token] = {:value =>

```

“#{current\_user.id};#{current\_user.active\_login\_key}”, :expires =\>  
1.year.from\_now.utc} if params[:remember\_me] == “1”  
redirect\_to CGI.unescape(params[:to] || home\_path)  
end  
end

If anyone could help, I’d really appreciate it.

---

<div class="post-metadata">

**Author:** ![GearSSS\_id\_OSCealla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@GearSSS\_id\_OSCealla](https://www.ruby-forum.com/u/GearSSS_id_OSCealla)\
**Post date:** [August 30, 2008, 10:13pm UTC](https://www.ruby-forum.com/t/working-with-sessions-in-beast-forum/147307/2 "2008-08-30T22:13:35Z")

</div>

On 30 Aug 2008, at 18:23, Gear¨®id O’Ceallaigh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I know that I have to set this value when a session is created but I’m  
> baffled about how (and where exactly) I have to do it. The following  
> code is used when creating a session:

IIRC session.model is the associated database row.

Fred

---

<div class="post-metadata">

**Author:** ![GearSSS\_id\_OSCealla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@GearSSS\_id\_OSCealla](https://www.ruby-forum.com/u/GearSSS_id_OSCealla)\
**Post date:** [August 30, 2008, 11:14pm UTC](https://www.ruby-forum.com/t/working-with-sessions-in-beast-forum/147307/3 "2008-08-30T23:14:26Z")

</div>

Riiight, could you expand on that? Thanks

On Aug 30, 9:12 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![GearSSS\_id\_OSCealla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@GearSSS\_id\_OSCealla](https://www.ruby-forum.com/u/GearSSS_id_OSCealla)\
**Post date:** [August 30, 2008, 11:28pm UTC](https://www.ruby-forum.com/t/working-with-sessions-in-beast-forum/147307/4 "2008-08-30T23:28:28Z")

</div>

On 30 Aug 2008, at 22:13, Gear¨®id O’Ceallaigh [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Riiight, could you expand on that? Thanks

Not much to say really - if the session is stored in the database with  
activerecordstore then session.model is the activerecord object for  
the corresponding row in the sessions table

Fred
