I'm developing my first project and I've done a some reading on maintain state across pages. From the few hours I've spent on the subject, it would appear that serializing and unserializing using $_SESSION seems a pretty simple and effective approach.
However, it seems to get frowned upon because of two main (and often disputed) reasons:
- Performance
- Security
I have a very typical (3 page) application process within my project 1>Select Category 2>Input Details 3>Confirmation => Add to database. And it makes sense to store the my object information within the $_SESSION.
On the performance front, the time to serialize the object was around 4 microseconds and to unserialize was 5 microseconds.
It would appear (from my reading) the preferred approach would be to use the actual datastore but surely to ask the database to save and retrieve this (often partial) information would take far longer and would result in a lot more code?
On the security front I understand the actual session information is stored on the server so isn't this secure?
I realise this has been asked before but the closest I found was asked 7 years ago
PHP: Storing 'objects' inside the $_SESSION
And was looking for more up to date opinions.