Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

autologin with existing cookies

Quote Reply
autologin with existing cookies
In leiu of GCommunity being availableWink, I have been trying to figure out how to "automagically" log my users into gforum if they have already signed in on another part of my site. When signed in they have a "username" and "password" cookie. I've done it by hacking GForum.pm, which I'd rather not.

Can anyone think of a snippet of code that could be used to take the cookies and auto-login the user when they visit gforum? I'm thinking that some code in a global variable that calls the cookies and then logs them in (if they aren't already) should do it, but I haven't figured out the "logs them in" part. Then the global could be called in the templates.

Or am I completely off track here?

Any ideas would be greatly appreciated.
Michael Coyne
seaturtle.org
Quote Reply
Re: [mcoyne] autologin with existing cookies In reply to
The best way to do this would be to add a plugin that hooks (via a post-hook) into auth_valid_session. Basically, it would look for the username and password cookie, and if found try to validate and set a cookie (Hint: most of the code you need to set the cookie properly is in GForum/Authenticate, sub auth_valid_session).

That way, when someone logs in, if they have cookies enabled, they will get a new GForum cookie - but it will happen automatically behind the scenes.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] autologin with existing cookies In reply to
Thanks Jason. That helped straighten some things out for me. I'm still trying to work out the hook thing, for some reason it makes my head hurt. How can you tell which bits of code can be hooked into? I believe I can get what I want to work if I can hook into and replace the authenticate sub in GForum.pm. That way I can take care of several different issues at one time with one hook instead of several different hooks into Authenticate.pm. I started working on a plugin, but it's not working the same way that my direct hack of the subroutine did. Is that subroutine even hookable?

thanks again,
Michael Coyne
seaturtle.org
Quote Reply
Re: [mcoyne] autologin with existing cookies In reply to
As of 1.1.4 is cannot be hooked into, however I've changed this for 1.1.5 to allow you to hook into the subroutine using the "authenticate" hook.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] autologin with existing cookies In reply to
Is it possible for me to easily make "authenticate" a hook in 1.1.4 so I can test my plugin until 1.1.5 comes out?
Michael Coyne
seaturtle.org
Quote Reply
Re: [mcoyne] autologin with existing cookies In reply to
1.1.5 should be out in less than an hour ;-)

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] autologin with existing cookies In reply to
Kewl, I'll stop bothering you then... Tongue
Michael Coyne
seaturtle.org
Quote Reply
Re: [Jagerman] autologin with existing cookies In reply to
In Reply To:
1.1.5 should be out in less than an hour ;-)

OK, so I take it there were serious problems with v1.1.5 Tongue since it's now about 5 days later. Or did I miss an announcement?
Michael Coyne
seaturtle.org
Quote Reply
Re: [mcoyne] autologin with existing cookies In reply to
Did you ever get this working? I'm trying to figure out how to do exactly the same thing. (I've been staring at the auth_valid_session subroutine in Authenticate.pm, but I'm scared to start changing things since my perl is still so lousy...)

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [mcoyne] autologin with existing cookies In reply to
Oops! Just found this thread:

http://www.gossamer-threads.com/...orum.cgi?post=198120

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund

Last edited by:

hennagaijin: Sep 13, 2002, 5:45 AM