Storing the current state of an application is a very difficult task. If you are building an application that is rendering its content on the server side you need to store the application state somehow on the server.
A good example for the described situation would be if a user is browsing a blog listing on page 2 and wants to comment on a certain post. When he clicks on the “add comment” link, the server side checks if the user has a valid session started and if not would send him to the login page. After logging in, the user expects to see the blog listing on page 2 with a comment form beneath the blog post preview.
To be able to store information about the current page, the action to be executed etc. I created a laravel package to solve the problem described above. This project is available on Github.
The idea behind the package is to be able to store information in the current users scope and get an identifier that can be used to access the stored information afterwards. The current version allows the developer to store the data in the users session or in a cache storage. Storing the data in a cache means that the state information is only accessible for a certain amount of time.
Details about installing, configuring and using the package are available in the repository’s README.
I plan to integrate a persistent storage for the state information (in particular a database table). This guarantees the user the access to the state information. This implementation needs also some sort of cleanup mechanism to remove not relevant state entries.