Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
kenji776 #1
Session variables no longer work
Hey everyone, bad news, my site is dying. The reason... session variables have
stopped working. For reasons unkown to me, the session scope seems to have
crapped out. When you go to login that works and it sets all the session
variables, and index.cfm knows about the session variables, but no other page
does. Every page keeps saying session.whatever is undefined, when it very
clearly is defined. No matter what I try the sessions just don't work. I can't
think of any idea why. I have gone to the point where I am manually passing
session information by using things like
<cfset manageswords123 =
"#URLSessionFormat("administration/manageswords.cfm")#">
<a href="#manageswords123#" target="_blank">Manage Sword Articles</a>
but that won't work for long, in fact it barely works at all becuase other
complexities. It is rather simple right now, either we figure out why session
variables don't work anymore, or i will be forced to close my site, because
they are a backbone of it. Please help, my site is my hobby and pet project, i
have been working on it for over a year, and i don't want to have to lose it.
Ill post my login.cfm code, and my applications.cfm code to see if anybody can
figure out why the sessions just don't seem to move from page to page like they
used to anymore.
<!--- APPLICATION.CFM--->
<html>
<head>
<META NAME="Description" CONTENT="DigitalSwordsmen.com - Free Music, Games,
Videos, Programs, FTP Server, Mail Server and more. We have info on swords,
anime, and video games. Free forums, and personl profile. Web log comming
soon.">
<META NAME="Keywords" CONTENT="Swordsmanship, swords, swordfighting, anime,
manga, snes, nes, gba, sega 3x, roms, free, downloads, music, games, programs,
ftp server, mail server, pop3 server, web log, personal profiles, forums, chat,
cool stuff, pictures, downloads.">
<title>Digital Swordsmen</title>
</head>
<body>
<cfapplication name="DigitalSwordsmen" sessionmanagement="yes"
sessionTimeout="#createTimeSpan(0,0,20,0)#" clientManagement="Yes">
<cflock scope="SESSION" timeout="20" type="EXCLUSIVE">
<cfif not isdefined("session.userlogin")>
<cfset session.userlogin ="guest">
<cfset session.userpassword = "">
<cfset session.firstname = "">
<cfset session.email ="">
<cfset session.userid = '0'>
<cfset session.userrole = "guest">
<cfset session.datasource = "users">
</cfif>
</cflock>
<cfif isdefined("session.userlogin")>
<cfquery datasource="messages" name="message_checker">
select *
from messages
where Reciever = '#session.userlogin#'
and
checked = 'no'
</cfquery>
<cfif message_checker.RecordCount greater than 0>
<cfloop query="message_checker">
<script>
<cfoutput>
alert("#message_checker.message# | From: #message_checker.fromwho#");
</cfoutput>
</script>
<cfquery name="checkit"
datasource="messages"
username="kenji"
password="cypher">
UPDATE messages
SET checked = 'yes'
WHERE messageID = #message_checker.messageID#
</cfquery>
</cfloop>
</cfif>
</cfif>
</body>
</html>
--------------------------------------------------------------------------------
------------------------------------------------------------------------------
<!--- Login.cfm --->
<html>
<head>
<title>Log In</title>
</head>
<body>
<cftry>
<cfform action="#cgi.script_name#" method="post" enablecab="yes"
name="loginform">
<table width="385" align="left">
<tr>
<td>Username:</td>
<td><cfinput name="userlogin" type="text" size="10" maxlength="100"
required="yes" message="Please Type Username First."></td>
<td>Password:</td>
<td><cfinput name="userpassword" type="password" size="10" maxlength="100"
required="yes" message="Please Type Password First."></td>
<td><input name="" type="submit" value="Enter"></td>
<td width="64"><font size="1"> Or <a href="accountadd.cfm"
target="blank">Register </a></td>
</tr>
</table>
</cfform>
<cfif not (isdefined("form.userlogin") and isdefined("form.userpassword"))>
<cfelse>
<cfquery name="userquery" datasource="users">
SELECT * FROM Users
WHERE Userlogin = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#form.userlogin#" maxlength="30">
AND UserPassword = <cfqueryparam cfsqltype="CF_SQL_VARCHAR"
value="#form.userpassword#" maxlength="30">
</cfquery>
<cfif userquery.RecordCount eq 1>
<cfquery name="loggedon"
datasource="users"
username="kenji"
password="cypher">
UPDATE Users
SET loggedon = 'no'
WHERE userID = #session.userID#
</cfquery>
<cfloginuser
name="#form.userlogin#"
password="#form.userpassword#"
roles="#userquery.UserRole#">
<cflock scope="SESSION" timeout="20" type="EXCLUSIVE">
<cfset session.userlogin = #userquery.userlogin#>
<cfset session.username = #userquery.userlogin#>
<cfset session.userID = #userquery.userID#>
<cfset session.userpassword = #userquery.userpassword#>
<cfset session.password = #userquery.userpassword#>
<cfset session.firstname = #userquery.firstname#>
<cfset session.userrole = #userquery.userrole#>
</cflock>
<cfquery name="loggedon"
datasource="users"
username="kenji"
password="cypher">
UPDATE Users
SET loggedon = 'yes'
WHERE userID = #session.userID#
</cfquery>
<cflocation url="index.cfm" addtoken="Yes">
<cfelse>
<script>
alert("Sorry, username/password combination invalid")
</script>
</cfif>
</cfif>
<cfcatch type="Any">
<p align="center"><font size="+1">File access has failed! Try again
later.</p>
<cfabort>
</cfcatch>
</cftry>
</body>
</html>
kenji776 Guest
-
Session.Variables do not work suddenly
This is a bit confusing. Do you mean that your session variables only exist on your site? This is normal behaviour? If you mean they are not... -
Session Variables do not work suddenly
Hi, I have a problem. When I define Session.Variables they only resists on the CFM-Site where I defined them. When I go further (maybe with a... -
#25870 [Opn->Bgs]: Session variables do NOT work as expected
ID: 25870 Updated by: sniper@php.net Reported By: memoimyself at yahoo dot com dot br -Status: Open +Status: ... -
#25870 [Bgs->Opn]: Session variables do NOT work as expected
ID: 25870 User updated by: memoimyself at yahoo dot com dot br -Summary: Session variables do NOT work as expected without... -
#25870 [Opn->Bgs]: Session variables do NOT work as expected without session_register()
ID: 25870 Updated by: iliaa@php.net Reported By: memoimyself at yahoo dot com dot br -Status: Open +Status: ... -
MikeyMike1981 #2
Re: Session variables no longer work
Hi
I know it sounds a bit daft but ...
Are you sure your application.cfm still exists?
is sessionmanagment enabled?
MikeyMike1981 Guest



Reply With Quote

