My app keeps calling OnSessionStart

I have a development environment using Coldfusion server. Everything was working fine until I wanted to try my code using Railo. I am not sure what I did but now when I am back using Coldfusion server I am finding that OnSessionStart is called each time I select something on my site and my session variables are not being saved. The only thing that I played with to try to get Railo to work was I changed a setting for the DefaultWebSite in my IIS manager but I believe I set that back to the original state.

Any clue what might be causing me to have problems with my session variables. I have checked that my sessionmanagement is on.

Thank you
WestCoast_BCAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
gdemariaConnect With a Mentor Commented:
you have two CFID and two CFTOKEN values set in the cookies, which tends to lead to the idea that you are setting cookies manually (or maybe ralio is).   Search your code for a CFHEADER or SET_COOKIE  or CFCOOKIE command to see.

Also, do you have only one version of ColdFusion running?   Are you doing any load balancing?

You may want to switch to jsession  which will no longer use those values - this is a simple setting in the CFIDE/administrator and should not harm your code at all unless you are manually using the CFID / CFTOKEN values.
0
 
WestCoast_BCAuthor Commented:
Does anyone have anything to suggest? I really need to get my development environment working again
0
 
Gurpreet Singh RandhawaWeb DeveloperCommented:
Can you show some of your application.cfc code for debug
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
gdemariaCommented:
how about the application definition showing session management turned on and timeout, how session variables are stored..
0
 
WestCoast_BCAuthor Commented:
I am thinking it has to be some setting that I changed in the setup because before I tried to get Railo running everything was working fine and I did not change any of the code. I did to a dump and it showed that session management is turned on and the timeout is 2 hours.  Also, when I use Railo it works fine using the same code.

Here is what I have in my Application.cfc
    <cfset THIS.ApplicationTimeout = CreateTimeSpan(0,4,0,0) />
    <cfset THIS.SESSIONTIMEOUT = CreateTimeSpan(0,2,0,0) />
    <cfset THIS.clientmanagement = true />
    <cfset THIS.SessionManagement = true />
    <cfset THIS.SetClientCookies = true />      
    <cfset THIS.Scriptprotect = 'none' />
0
 
dgrafxCommented:
is onSessionStart being triggered by something?

for example it's common to say something like:
<cfif Not StructKeyExists(session,"UserID")>
     <cfset onSessionStart()>
</cfif>

search for instances of "onSessionStart" in your application to see if you can track down this issue

even though you didn't change any code this might lead you to where it is being called and then why.
this is assuming that code is calling the new sessions and not that the previous session has timed out.
0
 
WestCoast_BCAuthor Commented:
I have just searched all of my code and I am not calling onSessionStart anywhere.

The same code works on my live site and when I am using Railo
0
 
dgrafxCommented:
You are using ColdFusion server on live site?
0
 
WestCoast_BCAuthor Commented:
Yes, I am using Coldfusion server on a live site.

My code had been working fine for a long time until I decided to try Railo. I thought I had documented all the things that I changed to try to get Railo working but I must be missing something.
0
 
dgrafxCommented:
I hate to say this but the easy fix might be to re-install CF ...
Or uninstall Railo - or both ...
0
 
WestCoast_BCAuthor Commented:
If I am using Railo express then I shouldn't have to uninstall it - am I correct?

I will do some more sleuthing before I try re-installing CF.
0
 
dgrafxCommented:
I can't answer that question.

It seems that I recall an issue years ago where sessions weren't sticking - don't recall the details ...

Anyway I fixed it by changing the Application name in Application.cfc. Then the next day I just changed it back again.
I don't know what was up other than simply a malfunction ???
You could try that plus you could check to make sure that you don't have duplicate CF Application names in different websites.
CF's rule is that you can't have duplicate Application names and only one site allowed with no name / per server.
And I see that you don't have a name attribute listed above - I would name it even if that isn't the problem.
<cfset This.NAME="surfgod">

good luck ...
0
 
gdemariaCommented:
Can you show your code in onSessionStart()?    Be aware that if there is an error inside of onSessionStart() then the session will not be created.   You may want to trap errors in there and send yourself an email if it fails.
0
 
dgrafxCommented:
Actually the session starts (and is created) whether intended session vars are set or not.
That's why I asked about calling onSessionStart() based on whatever condition as I stated above.
<cfif Not StructKeyExists(session,"whatever")>
     <cfset onSessionStart()>
</cfif>

But as far as trapping and logging errors - yes - I agree ...
0
 
WestCoast_BCAuthor Commented:
I have an onError in my application.cfc that dumps a bunch of information if I have an error. Do I need to add something to my onSessionStart as well to trap errors?
0
 
dgrafxCommented:
not necessarily ...
in the code that you call from onSessionStart do you have Try / Catch blocks that will prevent the onError function from being called? If yes then you can retool to email you those errors as well ...

BUT that is not your issue.

Try this: put a cfmail tag in your onSessionStart function (at the beginning of the function just in case there is an error that keeps the email from sending) that emails you a notification that a session has started. Just put a datetime stamp in it. This is just to test if indeed the session is starting frequently - every page load is it?
0
 
WestCoast_BCAuthor Commented:
I have added a call to cfmail in my onSessionStart. I added a call at the beginning and at the end of onSessionStart and I get both emails.  CFMail is being called on every page load.
0
 
gdemariaCommented:
Did you test whether or not your are able to save cookies?

Try doing a <cfdump var="#cookie#">
Do you see the session cookies?
Do they also change every page?
0
 
WestCoast_BCAuthor Commented:
I am setting session variables and they change on every page.

I am testing this by doing the following:
<cfset session.testval= now()>

and I include this in my email.  The value is changing with each page load
0
 
gdemariaCommented:
Depends on where you put that line..
   <cfset session.testval= now()>

If you put it in onRequestStart on on your page, then it should change, if you put it in onSessionStart then it should not change as onSessionStart should not be called every page view... but I think we determined that is is.

I am curious about the value of your CFIDE CFTOKEN values stored in the cookie, what happens when you dump the cookies?    If you have cookies off, your session will not work.
0
 
dgrafxCommented:
These are your settings right?
<cfset THIS.ApplicationTimeout = CreateTimeSpan(0,4,0,0) />
<cfset THIS.SESSIONTIMEOUT = CreateTimeSpan(0,2,0,0) />
<cfset THIS.clientmanagement = true />
<cfset THIS.SessionManagement = true />
<cfset THIS.SetClientCookies = true />      
<cfset THIS.Scriptprotect = 'none' />

AND you've added a name attribute?
<cfset This.NAME="whatever">
0
 
WestCoast_BCAuthor Commented:
Yes, I have this.name set.

session.cfid and session.cftoken value changes with each page load
0
 
dgrafxCommented:
>>session.cfid and session.cftoken value changes with each page load<<
which indicates a new session ??? weird ...

just re-install CF
I know this stuff can get interesting but that is my advice for quickest at this point - I said that earlier too so actually before this point.

It doesn't take long to re-install CF ...
0
 
gdemariaCommented:
Did you check the cookies or are you ignoring my comments?
0
 
WestCoast_BCAuthor Commented:
Sorry, I forgot about dumping the cookies.

I just dumped the cookies.  Here is what I get:


struct
AreCookiesEnabled      614
BPREVIEWMODE      0
CFADMIN_LASTPAGE_ADMIN      /CFIDE/administrator/debugging/index.cfm
CFAUTHORIZATION_cfadmin      YWRtaW4NNUJBQTYxRTRDOUI5M0YzRjA2ODIyNTBCNkNGODMzMUI3RUU2OEZEOA1jZmFkbWlu
CFCUEMAIL      sample@website.com
CFCUNAME      49
CFCUUID      513DAA6D-2E2B-446C-8EC71E4C5F9A5EC4
CFID      59252
CFID      59252
CFTOKEN      82450354
CFTOKEN      82450354
CF_CLIENT_ADREFLEX_SITE      {'USERID':1,'CUSTOMERID':'DA6FCB12-02-16-10','USERNAME':'sample@website.com'}
CF_CLIENT_ADREFLEX_SITE_HC      44
CF_CLIENT_ADREFLEX_SITE_LV      1406215565779
CF_CLIENT_ADREFLEX_SITE_TC      1406210011006
CHECKSESSION      0
CKFinder_Path      :/:1
CKFinder_Settings      TNNDS
RAILO_ADMIN_LANG      en
RAILO_ADMIN_LASTPAGE      debugging.logs
TimeZone      -08:00
TimeZone      -08:00
__atuvc      0|26,0|27,0|28,0|29,6|30
isDST      1
isDST      1
0
 
WestCoast_BCAuthor Commented:
Thanks, I manually deleted the cfid and cftoken values in the cookie and it seems to be working.  Thank you!
0
 
dgrafxCommented:
good job gdemaria
0
All Courses

From novice to tech pro — start learning today.