Yii Guest Sessions?

Just wondering if there is anything built in to handle guest sessions? Say you have functionality on your site where usually you have to be signed in to use, but you might want to provide some functionality to guests; obviously unless they are signed in you won’t be able to use the identity features of Yii, but was wondering if there was anything you could use to handle guests?

For example something that will set them a random username such as "Guest12345" and keep that in session as their username until the session expires and perhaps other info too?

…or will I have to create something myself!?


As far as the system is concerned, you are either logged in, or you are a Guest. If you want to allow functionality to a guest, that’s fine, just do that.

If you want to use a session, that’s also fine for a guest. A session is not the same as a logged-in user. The session uses a session id stored in a cookie so that when the user moves pages, the cookie will tell the server which session is being used.

Although you could create a temporary user for the guest, I don’t see how useful that is because you cannot link it to a real person or email address or anything else, so why not just let them be a guest?

Either way, you would have to code it yourself in Yii.

Ok, thanks!