Backport "Correctly set the cookie paths (see #5339)"