Skip to main content
Participant
August 17, 2007
Question

CFHTTP - maintianing session over multiple requests

  • August 17, 2007
  • 3 replies
  • 1130 views
I have to log into a form before I can go to the page I want. Is there any way to amintain the session across multiple cfhttp requests? I go to the first page and get logged in with no problems.
    This topic has been closed for replies.

    3 replies

    Inspiring
    August 21, 2007
    cfhttp gives you access to the cookies generated by the request. You just need to get the login page, grab the cookie(s) used for keeping the session and send the cookie(s) back on subsequent requests.
    SDSAuthor
    Participant
    August 21, 2007
    JohnEric, do you have an example of how to do that?
    August 22, 2007
    The following will allow your cfhttp call to share the same session as your calling template:

    <cfhttp URL="foo.cfm" method="get">
    <cfhttpparam type="cookie" name="cftoken" value="#session.CFToken#">
    <cfhttpparam type="cookie" name="cfid" value="#session.cfid#">
    </cfhttp>

    HTH.
    Inspiring
    August 20, 2007
    You could always code your own "session" within the variable page requests/output and append it to subquent CHTTP requests. That way you just pass whatever you generate in each "page" to the CFHTTP.

    eg:
    <cfset sessionvar = SomerandomizedTimeString>

    <cfhttp url=" http://www.url.com?mysession=sessionvar>

    Just keep appending this value -- would that work?

    -Chuck
    Participating Frequently
    August 17, 2007
    You may need to use a custom tag like cfx_http5 to maintain sessions