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: Ramsey Gurley <email@hidden>
- Date: Wed, 19 Nov 2014 12:00:19 -0700
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.
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.
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);
...
}
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