# Web service sessions

**URL:** <https://www.ruby-forum.com/t/web-service-sessions/101369>\
**Category:** Rails\
**Created:** [August 4, 2006, 3:33pm UTC](https://www.ruby-forum.com/t/web-service-sessions/101369 "2006-08-04T15:33:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [August 4, 2006, 3:33pm UTC](https://www.ruby-forum.com/t/web-service-sessions/101369/1 "2006-08-04T15:33:49Z")

</div>

I want to use ruby on rails entirely as an xml-rpc web service server.  
I.e. it will only be called by clients making xml-rpc requests. What I  
want to to is be able to use something like the session[] functionality  
for storing session information. However, storing information in the  
session[] construct requires that the client be a web browser with  
cookies enabled. Does anyone know of a simple way to impliment sessions  
across xml-rpc requests?  
Many thanks

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [August 4, 2006, 5:33pm UTC](https://www.ruby-forum.com/t/web-service-sessions/101369/2 "2006-08-04T17:33:35Z")

</div>

On Aug 4, 2006, at 8:33 AM, Peter Aszkenasy wrote:

> I want to use ruby on rails entirely as an xml-rpc web service server.  
> I.e. it will only be called by clients making xml-rpc requests. What I  
> want to to is be able to use something like the session[]  
> functionality  
> for storing session information. However, storing information in the  
> session[] construct requires that the client be a web browser with  
> cookies enabled. Does anyone know of a simple way to impliment  
> sessions  
> across xml-rpc requests?  
> Many thanks

I created a model that stores my web service sessions. When a user  
invokes the login method on the web service, they are assigned a  
token that is saved into the session model. When they log off, the  
token is deleted. In the meantime, they have to provide the token  
for every web service method invocation. I should write a program to  
scan through the sessions table to clean up stale ones, but the code  
never went into serious production so I haven’t needed to.

–  
~akk

> **[Adam Keys is typing](https://therealadam.com)**
>
> Developer and engineering manager at large

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [August 4, 2006, 5:41pm UTC](https://www.ruby-forum.com/t/web-service-sessions/101369/3 "2006-08-04T17:41:53Z")

</div>

Adam K. wrote:

> On Aug 4, 2006, at 8:33 AM, Peter Aszkenasy wrote:
> 
> I want to use ruby on rails entirely as an xml-rpc web service server.  
> I.e. it will only be called by clients making xml-rpc requests. What I  
> want to to is be able to use something like the session[]  
> functionality  
> for storing session information. However, storing information in the  
> session[] construct requires that the client be a web browser with  
> cookies enabled. Does anyone know of a simple way to impliment  
> sessions  
> across xml-rpc requests?  
> Many thanks

I created a model that stores my web service sessions. When a user  
invokes the login method on the web service, they are assigned a  
token that is saved into the session model. When they log off, the  
token is deleted. In the meantime, they have to provide the token  
for every web service method invocation. I should write a program to  
scan through the sessions table to clean up stale ones, but the code  
never went into serious production so I haven’t needed to.

–  
~akk  
[http://therealadam.com](http://therealadam.com)

Yep that’s kind of what I was thinking. I just wondered if there was a  
simple way of creating a persistant class without models and databases

---

<div class="post-metadata">

**Author:** ![mrpete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mrpete](https://www.ruby-forum.com/u/mrpete)\
**Post date:** [August 5, 2006, 4:51pm UTC](https://www.ruby-forum.com/t/web-service-sessions/101369/4 "2006-08-05T16:51:11Z")

</div>

On Aug 4, 2006, at 10:41 AM, Peter Aszkenasy wrote:

> Yep that’s kind of what I was thinking. I just wondered if there was a  
> simple way of creating a persistant class without models and databases

If you don’t need sessions to survive application restarts or if they  
don’t need to be shared across a cluster of application servers, you  
could create some object in your environment file and update just  
like you would the model. But if you want to share that session, you  
need it to live in some sort of shared store, like a database.

–  
Adam K.  
removed\_email\_address@domain.invalid
