JohnMac328
asked on
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
Any help is appreciated.
processwhensignupdone.txt loginprocess.txt
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?
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?
ASKER
Hi agx - I have to leave but we can pick this up on Monday if you are in.
Sounds good to me. Have a great w/e :)
ASKER
You too :)
<cfapplication name="MyApp" clientmanagement="Yes"
sessionmanagement="Yes"
sessiontimeout="#CreateTim
applicationtimeout="#Creat
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)
ASKER
Yes - that is just for testing purpose to see if the session kicks in after the membership signup
ASKER
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
Yes - both places I have a value of 0 but the data is being entered into the table
> 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.
ASKER
I did - no difference
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.
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.
ASKER
I actually started this question with agx. Thanks for your input though.
Lol, and you got so far...
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.
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.
... agx, maybe you want to see the code (tell him you want to see the code) .. he'll listen to you..
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 :)
lol. Man my timing stinks today. My Posts keep crossing ..
ASKER
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?
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>
<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>
ASKER
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_Logi n2\AA_Memb ershipSign up.cfm: line 82
80 : VALUES ('#FORM.user_name#','#FORM .user_pass #','#FORM. Email#','# FORM.first name#','#F ORM.lastna me#','#FOR M.zipCode# ','#FORM.F UND#','#FO RM.GROW#')
81 : </cfquery>
82 : <cfset session.user_id = Added.IDENTITYCOL>
83 : <cfset formResults="success" />
Element IDENTITYCOL is undefined in ADDED.
The error occurred in C:\Inetpub\wwwroot\CF_Logi
80 : VALUES ('#FORM.user_name#','#FORM
81 : </cfquery>
82 : <cfset session.user_id = Added.IDENTITYCOL>
83 : <cfset formResults="success" />
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great - thanks again as always.
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.
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.
ASKER
Open in new window
Open in new window