Remote Session Exisit?

Hi,
If I invoke a remote CFC/CFM from JQuery using AJAX ($.get), do the session variables still exisit for the caller?  It's a little hard to test.

Thanks,
hefterr
LVL 1
hefterrAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
_agx_Connect With a Mentor Commented:
Yes, there shouldn't be a difference. You're still calling the page from a browser, so the normal rules for sessions still apply.

     >  It's a little hard to test.

Create a cfc that returns info about the session (ie id and some variable) then call it from a test page.

Test Component:
   <cffunction name="testSession" access="remote" returnType="string">
            <cfargument name="arg" type="string" />
            <cfif not structKeyExists(session, "userName")>
                  <cfset session.userName = "bob"& randRange(1, 1000)>
            </cfif>
            <cfreturn "Session: "& session.sessionid &" userName="& session.userName &" called at "& now() />
   </cffunction>

Test Page:
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript">/script>
<script type="text/javascript">
      function test() {
            $.get('http://localhost/path/someComponent.cfc?method=testSession&arg='+ Math.random(), function(data) {
                    $('.result').html(data);
            });
      }      
</script>
<div class="result"></div>
<a href="javascript:test()">Test</a>
0
 
gdemariaConnect With a Mentor Commented:
Yes they do.  The session is kept alive through cookies which the cfc/m has available even through ajax
0
 
_agx_Commented:
{Sigh} ... EE really needs ajax notifications...
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
hefterrAuthor Commented:
@agx
{Sigh} ... EE really needs ajax notifications...

What do you mean by this?
0
 
hefterrAuthor Commented:
Thanks!!
0
 
_agx_Commented:
@hefterr - Nothing to do with your question, just 2 responses colliding ie saying the same thing at the same time... EE should have some sort of ajax notification to let you know new comments were posted while you were composing an answer. So you can edit/cancel your response if someone else already said some of the same things. Currently you don't know unless you refresh the page .. and you have to do it in a new tab/window so you don't lose the answer you're composing. Seems like a perfect job for ajax.
0
All Courses

From novice to tech pro — start learning today.