Use port number instead of process id for cookie key

Also try to use default 302 for redirection.