store referrer in cookie for page reload support.

document.referrer is lost if page is reloaded (timeout, error, ask customer ..) and user is trapped inside publish view because both submit and cancel buttons will stay on same url.
now the referrer is stored in a cookie so at least there is a chance for a valid back url. as fallback redirect to portal_url.