Javascript login with redirectTo returns null

I am using a custom login form to handle validating users on secure forms. I am now attempting to use cookies that are stored in the users browser to automatically log the user in when available.

On the login form, there is a RedirectTo field that stores the indended destination.

I use the following javascript in the OnLoad event of the form:

var x = readCookie(‘cookieName1’);

var y = readCookie(‘cookieName2’);

if (x == null){

//do nothing

}

else

{

var z = (document.forms[0].RedirectTo.value)

alert(z)

window.location = “/names.nsf?login&username=” + x + “&password=” + y + “&redirectto=” & z

}

The result is a 404 error with the following URL:

http://www.mydomain.com/web/wardwebs.nsf/0

Instead of using what was in the RedirectTo field, there is only a /0.

Notice the alert(z) in the code, it does display the proper url to redirect to.

Finally, if I hardcode the redirectto value into the line, it works. Like this:

window.location = “/names.nsf?login&username=” + x + “&password=” + y + “&redirectto=/web/wardwebs.nsf/reportrequest?openform”

Any ideas are appreciated.

-Jeremy

Subject: javascript login with redirectTo returns null

If your field is “hidden,” try this:

var z = document.all(“RedirectTo”).innerHTML;

location.href = “” + z;

Since the field is of type “hidden,” it is best to use innerHTML or innerText since the field is not “really” editable.

HTH