create cookie when user login

i need crete cookie when user login in portal

i’m use a “event handle”
event type = login
listener type= synchronous

HttpServletRequest request = PortalServlet.getCurrentRequest();  
MWSLoginEvent event = (MWSLoginEvent)getEvent();

Action action = event.getAction();
   if (action == MWSLoginEvent.Action.ACTION_LOGIN_SCRIPT_DONE) {

        Cookie cookie = null;
        Cookie[] cookies = request.getCookies();

        if (cookies != null){
		for (int i = 0; i < cookies.length; i++){
				if (cookies[i].getName().equals("CookieSession")){
					cookie = cookies[i];

		if (cookie == null){
			cookie= new Cookie ("CookieSession","aaaa");
			response.addCookie(cookie) ;

but resquest and response are null. PortalServlet.getCurrentRequest() not work for me…

Event handlers do not run in the context of the HTTP request, so your request object will always be null in this case.

Perhaps you could create the cookie using a custom auth handler or using a portlet on a custom start page.

How I can create a custom auth handler?