in reply to CGI::Session flush() functions

flush() writes the session object to disk (or database, or whatever you use as a storage backend).

When you store a new param in a session it will be lost after the end of your scriptunless you call flush.

Replies are listed 'Best First'.
Re^2: CGI::Session flush() functions
by jettero (Monsignor) on Aug 20, 2008 at 12:37 UTC
    I think it actually tries to flush when the Session object goes out of scope. I believe it fails to flush only when the script dies unexpectedly.

    UPDATE: No doubt. Explicitly flushing is better in every way. I was just saying that there are occasions where it will flush on its own, not terribly reliable, but they exist.

    -Paul

      Not only when it dies unexpectedly. I had a whole lot of cases of normal exits where it also failed to flush the session, which is why I recommend to always manually call $session->flush().

      The CGI::Session maintainers know of these problems, and encourage you to not rely on auto flushing.