Interesting!
Main Topics
Browse All TopicsI'm trying to login to yahoo mail using CFHTTP. I read and pass the cookies, yet i'm still not succesful. Any ideas?
Feel free to plug this code into a blank cfm page. It will produces a useable output.
<CFHTTP Method="Get"
URL="http://mail.yahoo.com
UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
Redirect="No">
<CFSET ChallengeStart=#Find(".cha
<CFSET ChallengeValue=#Mid(CFHTTP
<CFSET uStart=#Find(".u value=",CFHTTP.FileContent
<CFSET uValue=#Mid(CFHTTP.FileCon
<CFOUTPUT>
<b>GET LOGIN PAGE</b><br>
#CFHTTP.Header#<br><br>
<CFSET ThisCookie=#Left(CFHTTP.Re
<CFSET FirstCookieName=#Left(This
<CFSET FirstCookieValue=#Mid(This
Cookie Name=#FirstCookieName#<br>
Cooki Value=#FirstCookieValue#<b
</CFOUTPUT>
<CFHTTP Method="Post"
URL="https://login.yahoo.c
UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
Port="443"
Redirect="No">
<CFHTTPPARAM Type="Cookie" Name="#FirstCookieName#" Value="#FirstCookieValue#"
<CFHTTPparam Type="FormField" name="login" Value="morgansowden">
<CFHTTPparam Type="FormField" name="passwd" Value="12rifko12">
<CFHTTPparam Type="FormField" name=".src" value="ym">
<CFHTTPparam Type="FormField" name=".md5" value="">
<CFHTTPparam Type="FormField" name=".hash" value="">
<CFHTTPparam Type="FormField" name=".js" value="">
<CFHTTPparam Type="FormField" name=".last" value="">
<CFHTTPparam Type="FormField" name="promo" value="">
<CFHTTPparam Type="FormField" name=".intl" value="us">
<CFHTTPparam Type="FormField" name=".bypass" value="">
<CFHTTPparam Type="FormField" name=".partner" value="">
<CFHTTPparam Type="FormField" name=".u" value="#uValue#">
<CFHTTPparam Type="FormField" name=".v" value="0">
<CFHTTPparam Type="FormField" name=".challenge" value="#ChallengeValue#">
<CFHTTPparam Type="FormField" name=".yplus" value="">
<CFHTTPparam Type="FormField" name=".emailCode" value="">
<CFHTTPparam Type="FormField" name="pkg" value="">
<CFHTTPparam Type="FormField" name="stepid" value="">
<CFHTTPparam Type="FormField" name=".ev" value="">
<CFHTTPparam Type="FormField" name="hasMsgr" value="0">
<CFHTTPparam Type="FormField" name=".chkP" value="Y">
<CFHTTPparam Type="FormField" name=".done" value="http://mail.yahoo.c
</CFHTTP>
<CFOUTPUT>
<b>POST LOGIN INFO</b><br>
#CFHTTP.Header#<br><br>
</CFOUTPUT>
<CFLOOP From="1" To="4" Index="Count">
<CFIF FindOneOF("; ",CFHTTP.ResponseHeader['S
<CFSET ThisCookie=#CFHTTP.Respons
<CFELSE>
<CFSET ThisCookie=#Left(CFHTTP.Re
</CFIF>
<CFSET CookieName=#Left(ThisCooki
<CFSET CookieValue=#Mid(ThisCooki
<CFOUTPUT>
Cookie Name=#CookieName#<br>
Cookie Value=#CookieValue#<br><br
</CFOUTPUT>
</CFLOOP>
<CFHTTP Method="Get"
URL="#CFHTTP.ResponseHeade
UserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
Port="443"
Redirect="No">
<CFLOOP From="1" To="4" Index="Count">
<CFIF FindOneOF("; ",CFHTTP.ResponseHeader['S
<CFSET ThisCookie=#CFHTTP.Respons
<CFELSE>
<CFSET ThisCookie=#Left(CFHTTP.Re
</CFIF>
<CFSET CookieName=#Left(ThisCooki
<CFSET CookieValue=#Mid(ThisCooki
<CFHTTPPARAM Type="Cookie" Name="#CookieName#" Value="#CookieValue#">
</CFLOOP>
<CFHTTPPARAM Type="Cookie" Name="#FirstCookieName#" Value="#FirstCookieValue#"
</CFHTTP>
<CFOUTPUT>
<b>RESULT OF LOGIN</b><br>
#CFHTTP.Header#<br><br>
#CFHTTP.ErrorDetail#<br><b
#CFHTTP.FileContent#<br><b
</CFOUTPUT>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I've downloaded and tested CFX_HTTP5. It works much better than cfhttp as it seems to automatically handle cookies and redirects without the need for extra programming. That tip itself is worth the answer, so thank you.
I'm quite poor with JS, so was wondering how much of that is essential? Once I have the returned html page in some kind of variable, I'm quite happy parsing the string myself.
What would the above code look like without the JS?
It is difficult to say what happens next (you can login normally an to see using Vies Source), but on the page above you have to construct next URL (main frame of mail app) using expression:
loadMain(gWelcomePage + "&rand=" + newDate.getTime());
This is what browser suppose to execute. SInce there is no browser, you have to cook your next URL on your own. Same with the other frame, if it is needed. So, you should seriously consider whether it worth it.
Business Accounts
Answer for Membership
by: INSDivision6Posted on 2005-05-15 at 17:15:10ID: 14007471
I was able successully pass login up to the main mail page using CFX_HTTP5 tag instead of CFHTTP. However, the mail page is a frameset. Some heavy JS business starts there. The final page looks like:
m/us.yimg. com/lib/pi m/r/medici /9_11/ mail /mailcommo nlib.js">< /script>
n.href = currentURL();
{ return gUrlExtras; }
l){ gFrom = fromval; } val){ gTitle = titleval; } l){ gBody = bodyval; } l){ gKind = kindval; } e){ gUrlExtras = ue; }
tion.repla ce( currentURL() );
n.replace( url );
pose();", mill);
Compose(); ", mill);
.com/ym/we lcome?YY=7 9670"; .com/ym/lo gin?YY=796 70";
plit("@", 1)[0] ;
rl); Name);
n.href != "about:blank" )
ieName);
m uncompressed/chunked Sun May 15 16:49:08 PDT 2005 -->
tags/cfxht tp5.cfm. My code:
/" SESSION="START" OUT="OUT">
lenge value=", OUT)>
asswd=12ri fko12"> &.hash=&.j s=&.last=& promo=&.in tl=us&.byp ass="> #uValue#&. v=0&.chall enge=#Chal lengeValue #&.yplus=& .emailCode ="> .ev=&hasMs gr=0&.chkP =Y&.done=h ttp://mail .yahoo.com ">
om/config/ login?" METHOD="POST" SESSION=#HTTPSESSION# BODY=#BODY# OUT="OUT">
<!--web31405-->
<html>
<title> Yahoo! Mail - morgansowden@yahoo.com </title>
<noscript>
<META HTTP-EQUIV=Refresh CONTENT="0; URL=/ym/login?nojs=1">
</noscript>
<script type="text/javascript" src="http://us.js1.yimg.co
<script>
function showCompose(body, to, from, title, cc, kind, urlExtras )
{
//if(body != null)
if( arguments.length >= 5 )
{
gBody = body;
gTo = to;
gFrom = from;
gTitle = title;
gCc = cc;
gKind = kind;
gUrlExtras = urlExtras;
}
else
{
gBody = gTo = gFrom = gTitle = gCc = gKind = gUrlExtras = "";
}
ymailmain.document.locatio
}
function currentURL()
{
return '/ym/instacompose?'+ gEmail+getComposeIter() ;
}
var gBody = "";
var gTo = "";
var gFrom = "";
var gTitle = "";
var gCc = "";
var gKind = "";
var gUrlExtras = "";
function getReplyForwardTo(){ return gTo; }
function getReplyForwardFrom(){ return gFrom; }
function getReplyForwardTitle(){ return gTitle; }
function getReplyForwardBody(){ return gBody; }
function getReplyForwardCc(){ return gCc; }
function getReplyForwardKind(){ return gKind; }
function getReplyForwardUrlExtras()
function setReplyForwardTo(toval){ gTo = toval; }
function setReplyForwardFrom(fromva
function setReplyForwardTitle(title
function setReplyForwardBody(bodyva
function setReplyForwardCc(ccval){ gCc = ccval; }
function setReplyForwardKind(kindva
function setReplyForwardUrlExtras(u
function refreshCompose()
{
incrementComposeIter();
loadCompose();
}
function loadCompose()
{
ymailcompose.document.loca
}
function loadMain(url)
{
ymailmain.document.locatio
}
function asynchLoadCompose(mill)
{
window.setTimeout("loadCom
}
function asynchRefreshCompose(mill)
{
window.setTimeout("refresh
}
function getComposeIter()
{
var composeIter = null;
composeIter = getICCookie();
return composeIter;
}
function seedComposeIter()
{
var newDate = null;
newDate = new Date();
var timeStampInMillis = newDate.getTime();
composeIter = timeStampInMillis;
setICCookie(composeIter);
}
function incrementComposeIter()
{
var composeIter = getComposeIter();
composeIter++;
setICCookie(composeIter);
}
var gWelcomePage = "http://us.f314.mail.yahoo
var gLoginUrl = "http://us.f314.mail.yahoo
var gTargetPage = null;
var gEmail = "morgansowden@yahoo.com".s
var gTheFrameset = true;
function initFrameset()
{
if(top != self)
{
safeReloadFrameset(gLoginU
return;
}
removeCookie(gReloadCookie
var composeIter = getComposeIter();
if( composeIter == null )
seedComposeIter();
if( ymailmain.document.locatio
{
return;
}
var framesetCookie = getFramesetCookie();
var redirectUrl = null;
if(framesetCookie != "http://mail.yahoo.com")
redirectUrl = framesetCookie ;
if( redirectUrl )
{
removeCookie(gFramesetCook
loadMain(redirectUrl);
}
else if( gTargetPage )
{
loadMain(gTargetPage);
}
else
{
var newDate = new Date();
loadMain(gWelcomePage + "&rand=" + newDate.getTime());
}
asynchLoadCompose(0);
}
</script>
<frameset ROWS="100%,*,*" border=0 onload="initFrameset();" >
<frame name="ymailmain" id="ymailmain" >
<frame name="ymailcompose" id="ymailcompose" frameborder=0 noresize>
</frameset>
</html>
<!-- v3.301.10.16.2 1115757615 -->
<!-- 0.05786 -->
<!-- web31405.mail.mud.yahoo.co
CFX_HTTP5 is available here: http://www.cftagstore.com/
<cfoutput>
<CFX_HTTP5 URL="http://mail.yahoo.com
<xmp>#OUT#</xmp>
<CFSET ChallengeStart=Find(".chal
<CFSET ChallengeValue=Mid(OUT, (ChallengeStart+18), 28)>
<CFSET uStart=Find(".u value=", OUT)>
<CFSET uValue=Mid(OUT, (uStart+10), 13)>
<CFSET BODY="login=morgansowden&p
<CFSET BODY="#BODY#&.src=ym&.md5=
<CFSET BODY="#BODY#&.partner=&.u=
<CFSET BODY="#BODY#&pkg=&stepid=&
<CFX_HTTP5 URL="https://login.yahoo.c
<xmp>#OUT#</xmp>
<cfset out=Left(OUT, Find('">click here', OUT)-1)>
<CFSET urlStart=Find('a href="', OUT)>
<CFSET urlValue=Mid(OUT, (urlStart+8), Len(OUT))>
<CFX_HTTP5 URL=#urlValue# SESSION=#HTTPSESSION# OUT="OUT" SESSIONEND="Y">
<xmp>#OUT#</xmp>
</cfoutput>