Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Session Handling

Yaws provides a nice API for handling sessions with cookies with the yaws_api:new_cookie_session/1-3 functions. The basic function new_cookie_session/1 takes a state record that can be specified by the application. This record can be retrieved by the function yaws_api:cookieval_to_opaque/1.

To update the session data, use the function yaws_api:replace_cookie_session/2 with the name of the cookie and the new state value.

In addition to the new_cookie_session/1 function, there is also a new_cookie_session/2 that takes a timeout (TTL) value after which the cookie session will be cleared. In new_cookie_session/1 the session will time out after a default period of time.

If some form of cleanup after a session ends is desired, use the new_cookie_session/3 function. In addition to a state variable and a TTL, this function also takes a PID for a cleanup process. When a session ends, it will send that process a message of the form {yaws_session_end, Reason, Cookie, Opaque}. Reason can be timeout or normal.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint