Jump to content

moogal

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

moogal's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. It couldn't really be set anywhere else. There's no specific path you have to follow to get the message to come up - the point of me putting it in the session was that I could then have it display on whichever page the user goes to next, so it's a bit difficult to post code as I have no way of controlling which page they then move on to. The only way that the variable is ever modified or accessed is via the two methods above. What I've just tried is putting a counter variable in, so that each time the message is set, the counter is incremented and displayed with the message. This worked as expected - the same counter value was displayed on every page until another page set a different message, which makes me think it's not being set on each subsequent page. I'm trying something else at this very moment - moving the variable into a class stored in the session just to see if that makes any difference.
  2. Hi, I'm having a bizarre problem with a project I'm working on. Basically, on completion of certain functions I need to display a message to the user on the next page they visit, so I have a function which sets a session variable with the message text. Then, on page load, there is another function which checks if this has been set, and if so displays the message and unsets the session variable. The problem I'm having is that on some pages, despite the session variable being unset, the message keeps appearing until I log out/clear the session completely. I've tried dumping the session and the variable is definitely being unset in the right place. I have no idea why this should be happening, and Googling didn't turn up anything useful. Has anyone encountered anything similar to this, and if so - any tips for solving it? Thanks in advance (from me and my sanity!) A (simplified) example of the code in question: function flash($strMessage) { $_SESSION['message'] = $strMessage; } function showFlash() { if(isset($_SESSION['message']) { echo "<div class='flash'>{$_SESSION['message']}</div>"; unset($_SESSION['message']); } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.