coldfusion - Sessions w/CFWheels not sticking -


i having difficulty having session values stick when create them. default value exists @ times. below rudimentary login tool.

the compare function works fine, when after cflock , redirect, session.userid , session.isloggedin still 0 , false, respectively.

config/app.cfm

<cfset this.name = "xxx"> <cfset this.sessionmanagement = true /> <cfset this.sessiontimeout= createtimespan(0,2,0,0) /> <cfset this.setclientcookies = false /> <cfset this.datasource = "xxx" /> 

events/onrequeststart.cfc

<cfscript>     if ( !structkeyexists(session, "userid") ) {         session.userid = 0;         session.isloggedin = false;     } </cfscript> 

controllers/admin.cfc

<cfcomponent extends="controller">     <cffunction name="init">      </cffunction>      <cffunction name="login">      </cffunction>      <cffunction name="main">      </cffunction>      <cffunction name="login_proc">         <cfset local.username = "xxx" />         <cfset local.password = "yyy" />          <cfif ispost() , structkeyexists(params, "username")>             <cfif compare(params.username, local.username) eq 0 , compare(params.password, local.password) eq 0>                  <cflock scope="session" type="exclusive" timeout="3">                   <cfset session.userid = local.username />                   <cfset session.isloggedin = true />                 </cflock>                  <cfset redirectto(action="main")>             <cfelse>                 <cfset                     flashinsert(                         error_msg="incorrect login."                 )>                 <cfset redirectto(action="login")>             </cfif>         <cfelse>             <cfset redirectto(action="login")>         </cfif>     </cffunction> </cfcomponent> 

views/admin/login.cfm

<cfform action="/-rootdir-/index.cfm/admin/login_proc" method="post">         <p>             <label for="login">username</label>             <cfinput type="text" name="username" size="20" required="yes" message="enter username" autofocus />         </p>         <p>             <label for="password">password</label>             <cfinput type="password" name="password" size="20" required="yes" message="enter password" />         </p>          <input type="submit" name="login" value="go" />     </cfform> 

it's line in config/app.cfm causing trouble:

<cfset this.setclientcookies = false /> 

with setclientcookies set way have it, cfid, cftoken, jsessionid, etc. cookies not being passed client, , coldfusion has no information client's session after redirect happens.

if absolutely must have setting, need pass cfid , cftoken in of redirects , links.

<cfset redirectto(action="main", addtoken=true)>  <!--- can't use linkto anymore unless override `urlfor` in controller use coldfusion's built-in urlsessionformat() function ---> <a href="#urlsessionformat(urlfor(action='main'))#>my link</a> 

i doubt want behavior though.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -