Got work experience in 2 weeks and need to learn coldfusion fast...

Discussion in 'Programming' started by <%xasp%>, Apr 28, 2007.

  1. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #21
    Shot in the dark here, but do you have cookies enabled in your browser?
     
    cfStarlight, May 4, 2007 IP
  2. <%xasp%>

    <%xasp%> Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #22
    c:\wwwroot\cfsites\dw1\Application.cfc
    c:\wwwroot\cfsites\dw1\index.cfm

    127.0.0.1/cfsites/dw1/index.cfm

    I can connect to databases fine and it picks up query variables so I don't think it is the path.
     
    <%xasp%>, May 4, 2007 IP
  3. <%xasp%>

    <%xasp%> Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    Yea cookies are enabled.
     
    <%xasp%>, May 4, 2007 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #24
    Did you try IsRoss()'s earlier suggestion about dumping the session scope at the top of index.cfm to see what's being set?
    <cfdump var="#session#">
     
    cfStarlight, May 4, 2007 IP
  5. <%xasp%>

    <%xasp%> Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #25
    Just tried it and get the error:

    Variable SESSION is undefined.
     
    <%xasp%>, May 4, 2007 IP
  6. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #26
    So its not creating any session variables at all. Weird. You've tried most of the tests I can think of off the top of my head like:

    1. Are session variables are enabled in the cf admin?
    2. Is the Application.cfc/cfm in the correct directory?
    3. Is the Application.cfc/cfm file name spelled correctly?
    4. Are cookies enabled?
    5. Is the cfapplication statement correct?
    6. Is the code using cflocation anywhere?

    This person had a similar problem but there's no resolution
    http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:47908

    Have you tried a simple test at the wwwroot level?
     
    cfStarlight, May 4, 2007 IP
  7. <%xasp%>

    <%xasp%> Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #27
    I changed the Application.cfc to:

    <cfcomponent>
    <!--- THIS refers to the Application.cfc settings --->
    <cfset THIS.name = "GetLeadApp" />
    <cfset THIS.SessionManagement = true />
    <cfset THIS.SessionTimeout = CreateTimeSpan(0,0,45,0) />
    <cfset session.GetLeadApp = "this_is_a_test" />
    </cfcomponent>

    and the index.cfm to:

    <a href="index.cfm?attatch=1234567890987654321">Check it!</a><p>
    <cfset session.GetLeadApp = "this_is_a_test1234567890" />
    <cfif IsDefined("URL.attatch")>
    <cfoutput>#attatch# and #session.GetLeadApp#</cfoutput>
    </cfif>

    and it works and it changes if I put the following above the <cfif>:

    <cfset session.GetLeadApp = "this_is_a_test1234567890" />

    but if it goes below the <cfif> it does not change

    It must be the server, I will reinstall it tomorrow.

    Thanks for your help.
     
    <%xasp%>, May 4, 2007 IP
  8. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #28
    So session variables are working now? You're not getting a SESSION variable undefined error any more?

    I'm curious. Why did you change the code in the sample Application.cfc? I only ask because I'm not sure the change you made will produce the expected results.
     
    cfStarlight, May 4, 2007 IP
  9. <%xasp%>

    <%xasp%> Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #29
    Yes the above code seems to work, but does not change with:

    <cfset session.GetLeadApp = "this_is_a_test1234567890" />

    Below the <cfif> statment only above.

    The only thing I can think of to make this happen is coldfusion checks the Application.cfc every time a new page is called and changes it back to the default session setting:

    <cfset session.GetLeadApp = "this_is_a_test" />


    ???
     
    <%xasp%>, May 5, 2007 IP
  10. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #30
    On second thought, I'm not convinced session variables are really working. I suspect the only reason you're not getting an error is because you're setting the variable on the index.cfm page. But its its being treated as a local variable (not a session variable). That could also explain why the value isn't changing. Using the original code, if you dump the session scope you should see at least these keys:

    CFID, CFTOKEN, SESSIONID

    If you dump it and don't see those keys, or get a Variable SESSION undefined error, then that's your problem. Its not the code, its that session variables still aren't working.

    It looks like you're using Dreamweaver ? (which I know absolutely nothing about) The other thread I posted mentioned something about the _mmserverscripts directory being required by DW.

    It sounds like you originally overwrote the Application.cfc/cfm file in that directory. Maybe its causing a problem now? From the comment above, it sounds like you don't want to overwrite/move the files in the _mmserverscripts directory. Just leave them as is and create your own (separate) Application.cfc files in your project directory

    c:\wwwroot\cfsites\dw\


    Does DW create an _mmserverscripts directory for each new project? If so, can you try again with a new project.
     
    cfStarlight, May 5, 2007 IP
  11. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #31
    <%xasp%>,

    Like I said, I'm not yet convinced session variables are really working :/ So you need to find the answer to that question first.

    But in response to your previous comment, IF session variables really were working correctly ..

    That's what's supposed to happen. ColdFusion will check the Application.cfm/cfc every time a .cfm page is called.

    You'll notice my original example is different than the code you're using. My example uses the "onSessionStart()" method. The onSessionStart() method is called (once) when a new session starts. Not called every time a cfm page is called. So the variable should be initialized only once. Not overwritten every time a page is requested.

    I know you're just trying to get the code to work. I only mention this to explain how changing the code might change the behavior. But again, this behavior only applies if session variables really _are_ working correctly.
     
    cfStarlight, May 5, 2007 IP
  12. <%xasp%>

    <%xasp%> Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #32
    I had a bit of a play and this seems to work fine:

    Application.cfm

    <cfapplication name="GetLeadApp" sessionManagement="Yes">

    index.cfm

    <cfif IsDefined("URL.attatch") and #session.GetLeadApp# eq "it_works">
    <h1>it_works
    <cfset session.GetLeadApp = "this_is_a_testwewqe1"></h1><p>
    NOW CLICK REFRESH AGAIN!!!<p>
    <cfelseif IsDefined("URL.attatch")>
    <cfoutput>#attatch# and #session.GetLeadApp#</cfoutput><p>
    NOW CLICK REFRESH!!!<p>
    <cfset session.GetLeadApp = "it_works">
    <cfelse>
    <cfset session.GetLeadApp = "this_is_a_testwewqe1">
    <a href="index.cfm?attatch=1234567890987654321">Check it!</a>
    </cfif><p>



    I have just checked with a new instalation your sample works fine to so all good.

    Also found a nice paging example:

    <cfparam name="start" type="numeric" default="1">
    <cfparam name="step" type="numeric" default="200">
    <cfquery datasource="datasource" cachedwithin=".01" name="queryResults">
    select url from your_table
    </cfquery>
    <cfif queryResults.recordcount gt 0>
    <cfoutput>
    <p>
    <!--- if past start --->
    <cfif (start-step-step) gt 1>
    <a href="#cgi.SCRIPT_NAME#?start=1"><img src="./images/beginning_blue.png" border=0 alt="Beginning" align="absbottom"></a>
    </cfif>
    <cfif start gt 1>
    <a href="#cgi.SCRIPT_NAME#?start=#start-step#"><img src="./images/previous_blue.png" border=0 alt="Previous" align="absbottom"></a>
    </cfif>
    <strong>#start# - #iif(start + step gt queryResults.recordcount,queryResults.recordcount,start + step-1)# of #queryResults.recordcount# records</strong>
    <!--- if still some not displayed --->
    <cfif (start + step) lte queryResults.recordcount>
    <a href="#cgi.SCRIPT_NAME#?start=#start+step#"><img src="./images/next_blue.png" border=0 alt="Next" align="absbottom"></a>
    </cfif>
    <cfif (start+step+step) lte queryResults.recordcount>
    <a href="#cgi.SCRIPT_NAME#?start=#queryResults.recordcount-step+1#"><img src="./images/end_blue.png" border=0 alt="End" align="absbottom"></a>
    </cfif>
    </p>


    results......

    Thanks again for your help
     
    <%xasp%>, May 6, 2007 IP
  13. irhusker

    irhusker Guest

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #33
    Any book by Ben Forta is also going to be a valuable resource.
     
    irhusker, Jul 10, 2007 IP