What are the alternatives to the SESSION OF VARIABLES?

What are the limitations of a session variable when developing a large web application. Also what are the best alternatives to session variables .

Please provide me alternatives to SESSION VARIABLES

+4
source share
4 answers

To understand the benefits of using sessions, you must understand how sessions work.

In the default settings

  • sessions are identified by a cookie in the user's browser and
  • session data is stored in memory on a web server

When a user sends a request to the server, the session cookie is sent together. It contains an identifier that the server uses to determine the data for a specific user session.

You can configure ASP.NET to

  • use request parameters instead of cookies to store session id
  • Store session data in a database (having a central data warehouse for session data is especially important if you have several servers serving your site).

Now about the benefits of disabling session state:

  • ASP.NET provides access to the session data stream through serialization of requests. This means that when session state is turned on, ASP.NET refuses to serve concurrent requests from the same user. This is especially true when a custom browser makes a lot of ajax requests. This problem can be mitigated by noting the state of the read-only session for queries where you do not need to update it.
  • When the request arrives, ASP.NET must retrieve the session data, and it must record data when the request ends. This may not be a big problem if the state of the session is stored in memory, but if the data is stored in a central database, it can cause serious performance problems.

Needless to say, these problems are compounded by storing large amounts of data for a large number of users.

For more information see

(The last article is a bit outdated, but still well read).

Alternatives

  • If you can, avoid the session state altogether.
  • If you absolutely need to associate the data with the user, use HTTP mechanisms and make the browser portable to the cookie or, possibly, the request parameter (this is partly the case with the entire REST movement).

Hope this helps.

+16
source

Pros and Cons of Session Variables See here

+1
source

It depends on the business logic of your application, in some cases a session may be the best choice, however there are many alternatives. The session should be used if you have different data for each request to your application, you can publish your data in hidden fields with your forms, but again ur question is a little track, you should analyze your requirement, than you should according to it to decide whether to use sessions or some other alternative solution, if I need to store the user ID than specifically, I will go to the sessions because they will be different for each user. I will not store very large data in a session, for example, by storing a dataset in a session that few developers have. Then also the questions arise if ur uses a session where you want to save it in the process or on the server, if ur saves the session on the server, it is very expensive, but in ssome scripts it is very useful.

+1
source

Since data in session state is stored in server memory, it is not recommended to use session state when working with a large amount of data. The session state variable remains in memory until you destroy it, so there are too many variables in the performance of the memory effect.

Session variables and cookies are synonymous. Therefore, if a user has determined that their browser does not accept any cookies, your session variables will not work for this particular web surfer!

An instance of each session variable is created when the user visits the page, and these variables are stored for 20 minutes AFTER the user leaves the page! (In fact, these variables are saved until they are timed out. This timeout length is set by the web server administrator. I saw sites where the variables will crash in just 3 minutes, while others that are saved for 10, and third, keep the default value of 20 minutes.) So, if you put any large objects in a session (for example, ADO record sets, connections, etc.), you need serious problems! As the number of visitors increases, your server will experience dramatic performance disruptions by placing large objects in a session!

0
source

Source: https://habr.com/ru/post/1494468/


All Articles