CookieModule.addCookie(new Cookie(cookieName, cookieValue, cookieDomain, cookiePath, null, false));
Cookie cookie = new Cookie(cookieName, cookieValue, cookieDomain, cookiePath, null, false); Log.log(Log.LEVEL_TRACE, MODULE, "Adding cookie: " + cookie); CookieModule.addCookie(cookie);
	protected AppletInfo getGRAppletInfo() {		AppletInfo info = new AppletInfo();		info.gallery = new Gallery(GalleryRemote._().getCore().getMainStatusUpdate());		info.gallery.setBlockWrites(true);		String url = getParameter("gr_url");		String urlFull = getParameter("gr_url_full");		String cookieName = getParameter("gr_cookie_name");		String cookieValue = getParameter("gr_cookie_value");		String cookieDomain = getParameter("gr_cookie_domain");		String cookiePath = getParameter("gr_cookie_path");		info.albumName = getParameter("gr_album");		Log.log(Log.LEVEL_INFO, MODULE, "Applet parameters:");		Log.log(Log.LEVEL_INFO, MODULE, "gr_url: " + url);		Log.log(Log.LEVEL_INFO, MODULE, "gr_url_full: " + urlFull);		Log.log(Log.LEVEL_INFO, MODULE, "gr_cookie_name: " + cookieName);		Log.log(Log.LEVEL_INFO, MODULE, "gr_cookie_domain: " + cookieDomain);		Log.log(Log.LEVEL_INFO, MODULE, "gr_cookie_path: " + cookiePath);		Log.log(Log.LEVEL_INFO, MODULE, "gr_album: " + info.albumName);		if (cookieDomain == null || cookieDomain.length() < 1) {			try {				cookieDomain = new URL(url).getHost();			} catch (MalformedURLException e) {				URL documentBase = getDocumentBase();				cookieDomain = documentBase.getHost();				Log.log(Log.LEVEL_INFO, MODULE, "URL probably doesn't have a host part because the Gallery " +						"is in (unsupported) relative mode. Using the Applet documentBase: " + cookieDomain);				try {					url = new URL(documentBase.getProtocol(), documentBase.getHost(), documentBase.getPort(),							url).toString();				} catch (MalformedURLException e1) {					Log.logException(Log.LEVEL_ERROR, MODULE, e1);				}			}		}		if (urlFull != null) {			// the server specified a full URL, we're probably in embedded mode			// and we have to recreate the URL			URL documentBase = getDocumentBase();			// if urlFull is indeed a full URL, use it			try {				URL urlFullU = new URL(urlFull);				if (urlFullU.getHost().equals(documentBase.getHost())						&& urlFullU.getPort() == documentBase.getPort()) {					info.gallery.setType(Gallery.TYPE_APPLET);					info.gallery.setApUrlString(urlFull);					Log.log(Log.LEVEL_TRACE, MODULE, "Full URL: " + urlFull);				} else {					Log.log(Log.LEVEL_TRACE, MODULE, "urlFull doesn't match documentBase for important data");					throw new MalformedURLException();				}			} catch (MalformedURLException e) {				Log.log(Log.LEVEL_TRACE, MODULE, "urlFull is not a valid URL: recomposing it from documentBase");				try {					String path = documentBase.getPath();					int i = path.lastIndexOf("/");					if (i != -1) {						path = path.substring(0, i);					}					urlFull = new URL(documentBase.getProtocol(), documentBase.getHost(), documentBase.getPort(),							path + "/" + urlFull).toString();					info.gallery.setType(Gallery.TYPE_APPLET);					info.gallery.setApUrlString(urlFull);					Log.log(Log.LEVEL_TRACE, MODULE, "Full URL: " + urlFull);				} catch (MalformedURLException ee) {					Log.logException(Log.LEVEL_ERROR, MODULE, ee);					urlFull = null;				}			}		}		if (urlFull == null) {			// old versions of Gallery, or bad urlFull			info.gallery.setType(Gallery.TYPE_STANDALONE);			info.gallery.setStUrlString(url);		}		info.gallery.cookieLogin = true;		CookieModule.discardAllCookies();		CookieModule.addCookie(new Cookie(cookieName, cookieValue, cookieDomain, cookiePath, null, false));		return info;	}