Re: Help with cookies and authenticate



Dan Winship <danw gnome org> writes:

> On 10/20/2011 01:02 PM, bsquared wrote:
>> 
>> Hello,
>> 
>> I am trying to figure out the correct way to use cookies with libsoup
>> and couchdb.  I have not been able to find an example of this, so I
>> thought I would ask here. I'm not sure it matters, but I am coding in
>> Vala.
>
> So, step one is that you want to add a SoupCookieJar to the session (via
> soup_session_add_feature()). You can either use the plain SoupCookieJar
> if you don't need persistence, or SoupCookieJarText or
> SoupCookieJarSqlite (in libsoup-gnome) if you want to keep the cookies
> between sessions.
>
>> If a user accesses a resource with user and password in the url 
>> ie. "user:passwd example com" I would like to use that information to
>> get a cookie from example.com/_session and then redirect the user to
>> their requested resource or handle a login error.
>> 
>> I am also curious as to how to handle the user:passwd info in the uri.
>> Should I discard it?
>
> It sounds like what you mean is that you want to look at the URI the
> user has requested before you pass it to libsoup, and if it contains a
> username and password, then first make a request to example.com/_session
> instead to get the cookie. Assuming that is successful, SoupCookieJar
> will store the cookie for you, and then you can just make the original
> request, after removing the username and password from the URL.
>
> (If example.com/_session is an HTML form, then you can use the functions
> in soup-forms.h to construct an appropriate form response.)
>
>> Also how should I handle a cookie that times out.
>
> SoupCookieJar will do that for you.
>
> -- Dan
>

Thank you, I'll try that today.  

I was trying to do this in the authenticate handler.    

Does that change anything?

-- 
Regards,
Brian Winfrey


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]