In the tutorial on CGI::Session there is the excerpt I paste at the end.
What I understand from it is that at the end of your login script session should automatically be flush()ed, close()d and destroyed.
Why is flush() not happening then?
CLOSING THE SESSION
Normally you don't have to close the session explicitly. It gets closed when your program terminates or session object goes out of scope. However in some few instances you might want to close the session explicitly by calling CGI::Session's close() method or undefining the object. What is closing all about - you'd ask. While session is active, updates to session object doesn't get stored in the disk right away. It stores them in the memory until you either choose to flush the buffer by calling flush() method or destroy the session object by either terminating the program or calling close() method explicitly.
In some circumstances you might want to close the session but at the same time don't want to terminate the process for a while. Might be the case with GUI and in daemon applications. In this case close() is what you want. Note: we prefer simpl undefing the session rather than calling close() method. close() is less efficient):
undef($session);
If you want to keep the session object but for any reason want to synchronize the data in the buffer with the one in the disk, flush() method is what you need.
Note: close() calls flush() as well. So there's no need to call flush() before calling close() |