In practice? No problem, if what you want is for an anonymous user or not to fill in a field in which after browsing any other page and returning to this, the field will always be filled in that session, the answer really is this.
Now a long answer:
The great constraint that people generally (or at least in my experience) make on saving data on SESSION
is in relation to the size of the information you are storing, that is, if this information is not so great there is no problem in doing this. Now what would be a big piece of information? Well, in the case of Session it depends a lot on the capacity of its Server, my recommendation, nothing that exceeds the 100kb of storage, let us take as an example the Cookies that has limit of 20 kb but on the other hand are sent and received to each request, so the SESSION
may be a little bigger.
The big question when to choose the type of storage form to adopt is to ask yourself questions such as:
- The information to store is great?
- The information is temporary or something that should be saved for a long time?
- The information is confidential?
With these questions I believe we can come to conclusions, for example:
- If not so big (100kb), temporary and confidential, I can save in session
- If small (2kb, 5kb), temporary and non-confidential, I can save cookies
- If it is large I must save it in a bank or file (hence it would be necessary to identify the user in some way).
Be clear that, I am not imposing rules, keep in mind that rules are very important but nothing is better than common sense, each situation has its best alternative even if it breaks patterns, as great writers have said: rules were made to be broken.
by javascript, you can use sessionStorage or localStorage if you find it more practical: http://zenorocha.com/html5-local-storage/ (this eliminates any sending of browser data to the server)
– Leonardo Bosquett
@Leonardobosquett Really, much easier the/
– Daniela Morais
And in case it is compatible with old browsers?
– Daniela Morais
very old browsers probably won’t have this feature, take a look here (but see that even IE8 supports the resource): http://caniuse.com/#feat=namevalue-Storage
– Leonardo Bosquett
Thank you all! Saved a lot of lines of code. @Lollipop Strange would be man hahaha programmer
– Daniela Morais