1fromplainimportmodels 2 3 4@models.register_model 5classSession(models.Model): 6""" 7 Plain provides full support for anonymous sessions. The session 8 framework lets you store and retrieve arbitrary data on a 9 per-site-visitor basis. It stores data on the server side and10 abstracts the sending and receiving of cookies. Cookies contain a11 session ID -- not the data itself.1213 The Plain sessions framework is entirely cookie-based. It does14 not fall back to putting session IDs in URLs. This is an intentional15 design decision. Not only does that behavior make URLs ugly, it makes16 your site vulnerable to session-ID theft via the "Referer" header.1718 For complete documentation on using Sessions in your code, consult19 the sessions documentation that is shipped with Plain (also available20 on the Plain web site).21 """2223session_key=models.CharField(max_length=40,primary_key=True)24session_data=models.TextField()25expires_at=models.DateTimeField()2627classMeta:28indexes=[29models.Index(fields=["expires_at"]),30]3132def__str__(self):33returnself.session_key3435defdecoded_data(self):36from.coreimportSessionStore3738# A little weird to init an empty one just to use the decode39returnSessionStore()._decode(self.session_data)