# Web services and login?

**URL:** <https://www.ruby-forum.com/t/web-services-and-login/52259>\
**Category:** Rails\
**Created:** [January 12, 2006, 9:15am UTC](https://www.ruby-forum.com/t/web-services-and-login/52259 "2006-01-12T09:15:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oliver\_Charles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/958977/32.png) [@Oliver\_Charles](https://www.ruby-forum.com/u/Oliver_Charles)\
**Post date:** [January 12, 2006, 9:15am UTC](https://www.ruby-forum.com/t/web-services-and-login/52259/1 "2006-01-12T09:15:29Z")

</div>

Has anyone managed to do this? I thought about using sessions but they  
dont want to work for me… Here’s what I’m doing as a little test:

class NotLoggedIn \< Exception

end

class ProjectsController \< ApplicationController  
wsdl\_service\_name ‘Projects’  
web\_service\_api ProjectsApi

def Login  
@session[:loggedIn] = true  
end

def GetProjects  
if @session[:loggedIn]  
return Project.find(:all)  
else  
raise NotLoggedIn, “You are not logged in!”  
end  
end

def CreateProject(name)  
Project.create(:name =\> name)  
return name \<\< “Wee”  
end  
end

Nothing fancy, but doing

ProjectService.Login();  
ProjectService.GetProjects();

in c#, gets a NotLoggedIn exception. Any ideas?

---

<div class="post-metadata">

**Author:** ![Oliver\_Charles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/958977/32.png) [@Oliver\_Charles](https://www.ruby-forum.com/u/Oliver_Charles)\
**Post date:** [January 12, 2006, 12:00pm UTC](https://www.ruby-forum.com/t/web-services-and-login/52259/2 "2006-01-12T12:00:54Z")

</div>

To take a guess (since I’m exploring Web services from the other side of  
things) I would expect that rails is using a cookie to maintain its  
session.  
In order for the second call to connect to the session in the rails  
application the cookies that are set in the response to the first call (  
ProjectService.Login()) need to be propagated back to the second call (  
ProjectService.GetProjects()).

If this isn’t happening then the call to GetProjects will not see a  
session  
cookie and will create a new session.

I would expect that .Net does the session and cookie management  
implicitly  
on the client. But it would seem from what I’ve been reading that Java  
doesn’t do this by default so maybe .Net is copying Java a little too  
closely on this one.

---

<div class="post-metadata">

**Author:** ![Oliver\_Charles](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/958977/32.png) [@Oliver\_Charles](https://www.ruby-forum.com/u/Oliver_Charles)\
**Post date:** [January 12, 2006, 3:54pm UTC](https://www.ruby-forum.com/t/web-services-and-login/52259/3 "2006-01-12T15:54:18Z")

</div>

Ah, that would make sense I suppose. Well, what do you think about  
having a list of currently logged in ips in a table? This app doesn’t  
need to be hugely realtime (and I doubt I’ll have massive tables, beyond  
a few meg even).

Unless you’ve got any other ideas?
