bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] wget login form sets cookie with javascript


From: Eric Coulthard
Subject: [Bug-wget] wget login form sets cookie with javascript
Date: Mon, 10 May 2010 22:30:17 -0600

Hello,

I have been trying to get wget to login automatically to a site and it keeps
redirecting me to a login page saying that my session has expired. One thing
about the login page is that it sets a cookie using javascript right before
the login form is submitted. I have tried many tricks to fix this but
nothing seems to work. I can login through my browser and copy the cookie
values. This seems to work but I would like my script to be self sufficient.

Here is the form tag:
<form name="form" method="post" action="
https://www.yourfavouritesite.com/login.asp"; onsubmit="return SetCookie()">

Here is the javascript function:

function SetCookie() {
  var idField = document.getElementById("idField");
  var cookieName = "ID";
  var cookieValue = idField.value;
  var nDays = 30;
  var today = new Date();
  var expire = new Date();
  if (nDays==null || nDays==0) nDays=1;
  expire.setTime(today.getTime() + 3600000*24*nDays);
  document.cookie = cookieName+"="+escape(cookieValue) +
";expires="+expire.toGMTString();
  return true;
}

Here is my current approach:

wget -O /dev/null/ --keep-session-cookies --save-cookies=cookies.txt
--header "Cookie: ID=myID;expires=Sun, 6 Jun 2010 09:09:07 UTC" --post-data
"ID=myID&password=mypassword" https://www.example.com/login.asp

Any help would be greatly appreciated.

Eric Coulthard

==================
Programmer Analyst


reply via email to

[Prev in Thread] Current Thread [Next in Thread]