• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

CF - problem with session id

I have a situation where they want a link to display with either an image of a padlock locked or unlocked depending on the login status of the user.  If they click on the link with the locked padlock they are taken to a login screen.  The login takes the username and password and inserts into tablemembership. They login and it displays the link with an unlocked image.  This works with no problems.  In addition they want a link to sign up in case they need to for obvious reasons.  I have made the signup form and it also works fine and after the form submits the same information into tablemembership, I have a link to go to the page with the links.  The problem is the link still shows a locked padlock image meaning that when they enter the page the session variable is not seeing that they have logged in.  How do I get the signup process to display the links like the login process does.

Any help is appreciated.
       processwhensignupdone.txt loginprocess.txt
0
JohnMac328
Asked:
JohnMac328
  • 10
  • 8
  • 5
1 Solution
 
JohnMac328Author Commented:
Page with the links and the application.cfm

<table width="400" border="0" align="center">
 <th>Investment Concepts</th>
	<cfif val(session.user_id)> 
 <tr>
    <td><a href="http://localhost/PopUp_Login/dl/book3.xls"><img src="unlocked.gif" width="35" height="35">
    <h3>Link to display if they have</h3></a>
    </td></tr>
  <cfelse>
 <tr>
    <td><A HREF="testlogin.html" onClick="return popup(this, 'notes')"><img src="locked.gif" width="35" height="35">
    <h3>Link to login if they have not signed up</h3></A>
    </td></tr>
  </cfif>
</table>

Open in new window

<cfapplication name="MyApp" clientmanagement="Yes"
                    sessionmanagement="Yes"
                    sessiontimeout="#CreateTimeSpan(0,0,0,10)#"
                    applicationtimeout="#CreateTimeSpan(0,0,0,10)#">

<!--- Now define that this user is logged out by default --->
<CFPARAM NAME="session.allowin" DEFAULT="false">

<!--- Now define this user id to zero by default, this will be used later on to access specific information about this user. --->
<CFPARAM NAME="session.user_id" DEFAULT="0">

Open in new window

0
 
_agx_Commented:
I have made the signup form and it also works fine and after the form submits the same information into tablemembership  ... How do I get the signup process to display the links like the login process does.

Are you actually logging them in after they sign up? Dump the value of #session.user_id# on the sign up page, and again on the page that's showing the locked icon.  Is the value 0?
0
 
JohnMac328Author Commented:
Hi agx - I have to leave but we can pick this up on Monday if you are in.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
_agx_Commented:
Sounds good to me. Have a great w/e :)
0
 
JohnMac328Author Commented:
You too :)
0
 
gdemariaCommented:


<cfapplication name="MyApp" clientmanagement="Yes"
                    sessionmanagement="Yes"
                    sessiontimeout="#CreateTimeSpan(0,0,0,10)#"
                    applicationtimeout="#CreateTimeSpan(0,0,0,10)#">


Your session and application timeout is only 10 seconds !    That means the session is thrown out with just 10 seconds after they login..

A more typical time for a session timeout is 20 minutes, and perhaps a few hours for an application

  CreateTimeSpan(0,0,20,0)

0
 
JohnMac328Author Commented:
Yes - that is just for testing purpose to see if the session kicks in after the membership signup
0
 
JohnMac328Author Commented:
agx - "Are you actually logging them in after they sign up? Dump the value of #session.user_id# on the sign up page, and again on the page that's showing the locked icon.  Is the value 0?"

Yes - both places I have a value of 0 but the data is being entered into the table
0
 
gdemariaCommented:

> Yes - that is just for testing purpose to see if the session kicks in after the membership signup

I don't understand your response...  you are aware of it?   but that IS the problem (or at least one of them).

You need to change it before you can test.  


0
 
JohnMac328Author Commented:
I did - no difference
0
 
gdemariaCommented:
Ok, that be sure to leave them  both (session and application timeouts) at longer durations while you do the rest of the testing.

If the problem is happening when the user is registering, please show the code that saves the info to the database and then creates the session.user_id.   Be sure not to use CFLOCATION after setting the session variable, it may not stick.
0
 
JohnMac328Author Commented:
I actually started this question with agx.  Thanks for your input though.
0
 
gdemariaCommented:
Lol, and you got so far...



0
 
_agx_Commented:
agx - Are you actually logging them in after they sign up? ... Dump the value of #session.user_id# ...Is the value 0?"
JohnMac328 - Yes - both places I have a value of 0 but the data is being entered into the table


#session.user_id# shouldn't be 0 because your code says a value of 0 means the user *isn't* logged in.  

<!--- if it's NOT 0 --->
<cfif val(session.user_id)>
    unlocked ...
<cfelse>
    locked
</cfif>

Sounds like the code *isn't* properly logging them in after sign up.  ie It isn't updating the session variable with the new user_id.
0
 
gdemariaCommented:
... agx, maybe you want to see the code (tell him you want to see the code) ..  he'll listen to you..
0
 
_agx_Commented:
I'm always happy to help when I'm around. But I'd actually recommend gdemaria's advice over a LOT of others in this zone when I'm not :)
0
 
_agx_Commented:
lol. Man my timing stinks today.  My Posts keep crossing ..
0
 
JohnMac328Author Commented:
Just did not know the protocol for questions. Ok, after I insert the records into the table it sounds like I need to create the session.user_id, what would that syntax be?  Just run it after the insert statement?
0
 
_agx_Commented:
I assume user_id is an identity column in sql server right?  For CF8+ just use the "result" attribute to get the new ID value

<cfquery result="newUser" ....>
          INSERT INTO YourTable ( ....) VALUES (.....)
</cfquery>

Then use it to set the value of your session variable.  

<cfset session.user_id = newUser.IDENTITYCOL>
0
 
JohnMac328Author Commented:
I get this error and yes user_id is an identity column - the query is called Added

Element IDENTITYCOL is undefined in ADDED.  
 
 
The error occurred in C:\Inetpub\wwwroot\CF_Login2\AA_MembershipSignup.cfm: line 82
 
80 :                   VALUES ('#FORM.user_name#','#FORM.user_pass#','#FORM.Email#','#FORM.firstname#','#FORM.lastname#','#FORM.zipCode#','#FORM.FUND#','#FORM.GROW#')
81 :              </cfquery>
82 :             <cfset session.user_id = Added.IDENTITYCOL>
83 :             <cfset formResults="success" />
 
0
 
_agx_Commented:
You have to use the "result" attribute, not "query".  The result name can be anything. Just make sure it's different than the query name.

<cfquery result="newUser" name="Added" ....>INSERT ....</cfquery>
<cfset session.user_id = newUser.IDENTITYCOL>
0
 
JohnMac328Author Commented:
Great - thanks again as always.
0
 
_agx_Commented:
You're welcome :)

Just did not know the protocol for questions.

Btw: It's nice that you asked :) In this case we hadn't gotten very far yet on Friday. So IMO someone else chiming in is totally fine.  Plus, if you have a question you need answered now, go with the expert that's present and available ;-)  If you feel multiple experts helped solve the problem, you can always accept multiple answers.  For more complicated/involved questions you might prefer to stick with one expert (if they're available). But that's all up to you.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 10
  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now