Session variables no longer work

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. #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: ...
    4. #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...
    5. #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: ...
  3. #2

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139