# Method SSL.Context()->encode_ticket()

Method encode_ticket

  ``array`(`string(8bit)`|`int`) encode_ticket(`Session` `session`)`

Description

  Generate a session ticket for a session.

Note

  The default implementation just generates a random ticket and calls record_session() to store it.

  Over-ride this function (and decode_ticket()) to implement server-side state-less session resumption.

Returns

  Array
  ``string(8bit)` `0`` | Non-empty string with the ticket.
  ``int` `1`` | Lifetime hint for the ticket.

Note

  If the context signals that it does offer tickets via offers_tickets(), this function must offer an encoded ticket for the session as the connection may have signalled to the client that a ticket will be offered. However, tickets are not guaranteed to be actually usable, so if you cannot offer a ticket when you must, `"INVALID"` might be an option...

See also

  decode_ticket(), record_session(), RFC 4507 section 3.3