简体   繁体   中英

alternate to sesssion variable is it serialization

This is a question I always wanted to ask. We always read that it is better to use request object when we have to carry data from one page to other. Now let's say I have about 10 different data items that I need on 4-5 pages. Is it better to use a session variable, or is there an alternative to that? In my app I have about 10 menus where each menu performs different operations. In each such menu I have such different data which are not common between menus. Which is the best way to handle this?

For that kind of problem (navigation) I prefer an stateless approach. This is, passing the info in the url or request body. An stateful approach is harder in the end, less scalable, consumes more memory for each user and, as any other global variable, you have to be very careful to handle it.

Remember that HTTP is an stateless protocol and then, and you should prefer an stateless design. The stateful approach is just a kind of trick that both sides (client and server) use to achieve the magic you know as session variables.

Send the required info in the request!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM