title: How to reset session variables
body: <p>I'm developing an app. in CF10. It's been decided that this app. will be opened through a link that is created in a dot net app.
  Users log in &amp; out through the dot net application in order to see the link. When users click on that link they can access the CF application.</p>
  
  <p>This link passes a user id, I'm using this user id to create session.userid
  in onSessionStart at application.cfc :</p>
  
  <pre><code>  &lt;cfset session.userid = #Trim(URL.userid)#&gt; 
  </code></pre>
  
  <p>The problem is, when I log out and log back in as a different user, my previous session.userid still exists. So I have two different session.userids
  In order to avoid this I thought I can do the following:</p>
  
  <p>in onSessionStart at application.cfc, I start with sessionIvalidate function:</p>
  
  <pre><code>   &lt;cfset sessionInvalidate() /&gt;
     &lt;cfset session.userid = #Trim(URL.userid)#&gt;
  </code></pre>
  
  <p>I thought every time the application start application.cfc ColdFsuion has to run through application.cfc then sessionInvalidate function will clean out existing session.userid then a new one is created so if I log in and out as a different users from the same computer then the application still maintains one session.userid.
  But unfortunately this approach does not work! I still get the older session while the new session is not created!</p>
  
  <p>What is the best approach to my situation if I can't do it using this logic.
  Should I re-set session.userid index.cfm instead?</p>