Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > DHTML setCookie to bypass login page.

Reply
Thread Tools

DHTML setCookie to bypass login page.

 
 
tungchau81@yahoo.com
Guest
Posts: n/a
 
      08-24-2006
Hi everybody,
In MainPage.jsp, I had simple code to redirect it to a page called
'http://123.123.123.123' . However, I want to bypass the login page
(http://123.123.123.123/login.htm) by setting cookie of authorization
token, so that it will point directly to
http://123.123.123.123/main.htm. Here is my code:

++++++++++++++++++++++++++++++++++++++++++++++++
<html>
<head>
<title></title>
var djConfig = {isDebug: true, debugAtAllCosts : true};
</script>
dojo.require("dojo.io");
dojo.require("dojo.io.cookie");
dojo.hostenv.writeIncludes();
</script>
function main() {
if (dojo.io.cookie.isSupported() == true) {
dojo.io.cookie.setCookie('xxx', 'yyy', null, null, null,
null);
var cookieValue = dojo.io.cookie.getCookie('xxx');
alert(cookieValue);
}
document.location = 'http://123.123.123.123';
}
</script>
</head>
<body onload="main();"></body>
</html>
++++++++++++++++++++++++++++++++++++++++++++++++++
alert(cookieValue) returns the correct value of the cookie. However, I
still can not bypass the login page.

I also tried the following approach, but then, alert(cookieValue)
returns null.
+++++++++++++++++++++++++++++++++++++++
dojo.io.cookie.setCookie('xxx', 'yyy', 90, '/', '123.123.123.123',
false);
var cookieValue = dojo.io.cookie.getCookie('xxx');
alert(cookieValue); /_/***returns null
++++++++++++++++++++++++++++++++++++++++

My MainPage.jsp was the result of a webwork action which is similar to
Struts action.

Is there anything I m doing wrong here? I am really stuck and do not
know what other approaches I should try. Any advice is greatly
appreciated.

P.S.: Here is the code of setCookie and getCookie in dojo library for
your preference:
dojo.io.cookie.setCookie = function(name, value, days, path, domain,
secure) {
var expires = -1;
if(typeof days == "number" && days >= 0) {
var d = new Date();
d.setTime(d.getTime()+(days*24*60*60*1000));
expires = d.toGMTString();
}
value = escape(value);
document.cookie = name + "=" + value + ";"
+ (expires != -1 ? " expires=" + expires + ";" : "")
+ (path ? "path=" + path : "")
+ (domain ? "; domain=" + domain : "")
+ (secure ? "; secure" : "");
}

dojo.io.cookie.set = dojo.io.cookie.setCookie;

dojo.io.cookie.getCookie = function(name) {
// FIXME: Which cookie should we return?
// If there are cookies set for different sub domains in the
current
// scope there could be more than one cookie with the same
name.
// I think taking the last one in the list takes the one from
the
// deepest subdomain, which is what we're doing here.
var idx = document.cookie.lastIndexOf(name+'=');
if(idx == -1) { return null; }
var value = document.cookie.substring(idx+name.length+1);
var end = value.indexOf(';');
if(end == -1) { end = value.length; }
value = value.substring(0, end);
value = unescape(value);
return value;
}

dojo.io.cookie.get = dojo.io.cookie.getCookie;

Tung Chau

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlink to Bypass login Priya Javascript 9 04-30-2010 07:35 AM
using a setcookie to send an email - value issue bonus Javascript 2 02-24-2008 01:24 PM
Bypass cookies using workstation login teddysnips@hotmail.com ASP .Net 0 12-13-2005 03:50 PM
Do any DHTML books cover contemporary DHTML? Steve Javascript 1 04-09-2005 04:16 PM
Bypass(exempt) site with Microsoft Proxy 2.0 =?Utf-8?B?Z3JpZmxldA==?= Microsoft Certification 0 06-02-2004 09:06 PM



Advertisments