Re: Setting a cookie from a NextPageDelegate in D2W
Re: Setting a cookie from a NextPageDelegate in D2W
- Subject: Re: Setting a cookie from a NextPageDelegate in D2W
- From: Fabian Peters <email@hidden>
- Date: Wed, 19 Nov 2014 20:35:16 +0100
Hi Ramsey,
Am 19.11.2014 um 20:00 schrieb Ramsey Gurley <email@hidden>:
> D2W creates stateful pages. There is already a cookie set for the session. If you store what state you need on the session, then you can retrieve it from there easily.
Yes, but this app keeps the session ID in the URL, mostly to allow multiple active sessions per browser.
> If you are going to somehow lose the session, setting a cookie is probably not a robust enough way to handle things. Example: User changes email from computer… “We sent you an email! Please open it and click the confirmation link”… How do you know the user won’t pick up their smartphone and check email from there? Or check in mail.app which pops open safari instead of chrome when they click. Or any other number of scenarios where the browser changes. In that case, you either need to set your state in the DB and pick it up by uuid when they click the link, or encrypt the state and store it in the link itself if it is a small amount of state.
The cookie is meant to provide a more convenient (for the user…) way to identify a legitimate activation request. If there's no cookie present, the user will have to login to complete the change of address.
> To answer your question, you can probably set a cookie using some kind of global cookie store and notifications without needing to modify anything happening with D2W. Listen for WORequestHandler.DidHandleRequestNotification, then
>
> public void didHandleRequest(NSNotification n) {
> WOContext context = (WOContext)n.object();
> WOCookie cookie = ...
> context.response.addCookie(cookie);
> ...
> }
Just what I was looking for, thanks!
Fabian
>
> On Nov 19, 2014, at 11:33 AM, Fabian Peters <email@hidden> wrote:
>
>> Hi,
>>
>> I'm implementing an email address change feature in a D2W app. In the course of this I'd like to set a cookie with a UUID. Alas, the NextPageDelegate interface requires me to return a WOComponent. Which seems to make it impossible to pass a cookie with the response, the component being generated via D2W. Is there any way I can handle this w/o using a custom page or a redirect to a DA that sets a cookie?
>>
>> Fabian
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden