Skip to main content
WolfShade
Legend
February 13, 2015
Question

Detect if a scoped variable is corrupted???

  • February 13, 2015
  • 1 reply
  • 266 views

Hello, everyone,

I'm curious to know (this does not currently affect anything I'm working on.. I'm just curious) if there is a way to detect if a scoped variable (like "session.username" or "request.dsn") value has been corrupted?  Or if the variable, itself, has been corrupted?

V/r,

^_^

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    February 14, 2015

    What do you mean by corrupted? The value of session.username mysteriously changing from 'bkbk' to '%8#A&o'? The variable name mysteriously changing from session.username to session.usrnm or just username? It is unclear so far what you mean.

    Furthermore, the qualification, 'scoped', may be redundant. Practically every ColdFusion variable has a scope.

    WolfShade
    WolfShadeAuthor
    Legend
    February 16, 2015

    Hi, BKBK!

    I'm not exactly sure what happened (it was over a year ago, I think), but on a project that I was working on used <cfif StructKeyExists(session,"userID")> to check for authentication.  There were a lot of users who would log on, and after a few hours were getting weird error messages, and as far as we could tell, the session.userID was present, but the value contained within was not a valid userID.  So, either the variable itself was corrupted, or the value within was corrupted, somehow.

    I'd like to avoid situations like that in the future, so I'm wondering if there is a way to detect if corruption has occurred for a variable in the session scope.

    V/r,

    ^_^

    BKBK
    Community Expert
    Community Expert
    February 16, 2015

    Ah, thanks for the explanation, WolfShade.

    From your description, there might be a subtle loophole in the code logic. It just might be that session.userID is defined in certain circumstances where the user is not logged in.

    If you could use another pair of eyes, I would review the relevant piece of code for you. If necessary, send it by private message.