Ajax can t read the latest session issue 5

Updated on technology 2024-02-08
3 answers
  1. Anonymous users2024-02-05

    Nowadays, there are many AJAX applications in web development. There are also a number of frameworks in this regard. Session expiration issues are encountered in applications.

    If it is not handled properly, it will affect the user experience and may also cause inexplicable problems.

    Everyone's correct. Scenario 1: Check if the content returned by ajax is tagged.

    In the web system, when a session expires, the system will generally return to the login screen when the user has an operation.

    Have the user re-enter their username and password. When a session expires, the content returned by the AJAX request should be the page of the login screen.

    Content (i.e., the HTML of the page of the landing screen). Determine whether the returned content is used to determine whether the session has expired.

    var result=;What is returned by ajax

    if('')>-1)

    or var r= ig;

    if(You can use the preceding method to determine whether the session has expired, and then handle the exception according to the specific business.)

    Solution 2: The returned result has a sign of whether the session has expired. It is also known as the true false pattern.

    This solution is typically used in conjunction with JSON.

    If the result returned is:

    var res={

    result":true, *session has not expired, false(session expired)*

    data" :""*Other data*

    if(res["result"])

    The session has not expired*

    else{session expires*.}

    Scenario 3: Make use of timestamps.

    Make a global variable on the page.

    var startdate;The last time AJAX accessed the server, date type

    if(new date().gettime()<30*60*1000)

    Assume that the session expires for 30 minutes*

    The session has not expired*

    else{session expires*.}

    Ha ha! do not trust the client

    Solution 4: Extend the expiration time of the session.

    There are performance issues with this scenario.

    Extend the expiration time of a session.

    client rounds out server. (AJAX rounds in the server or client, and the server maintains a persistent connection).

  2. Anonymous users2024-02-04

    jstl (sessionscope) is to be parsed in the background. You can't just replace it with js. Ajax can only be replaced by HTML and JS that the browser can parse.

    The content to be returned needs to be processed in the background and then replaced with js in the foreground page.

    Be careful when using AJAX:

    1.For example, tags and el expressions, they can no longer be parsed in the foreground.

    After returning, he can only perform js operations, that is, the browser itself can parse.

  3. Anonymous users2024-02-03

    I can see that you don't know much about sessions.

    Session is a **-level user state object, which has nothing to do with which page the page is, only with which program.

    As long as it's the same **, you can pass the session[.]"Your name"] to get your previously saved session (provided that the session does not expire), so you can also use the session on your newly added aspx page

    If the session expires, wouldn't it be enough to let the user log in again?

Related questions
11 answers2024-02-08

Set up the computer to be used in the local area network, and the relevant services can be restored. (Friendly reminder: Friends who have inadvertently turned off printer-related services can also use this method to restore the use of the printer);

3 answers2024-02-08

1. Dual memory is incompatible, memory quality problems replace memory modules. The memory and motherboard are not plugged in properly or other hardware is not compatible Reinsert the memory or change the socket . >>>More

2 answers2024-02-08

Legal analysis: The so-called inability to enforce refers to the situation where the person subject to enforcement really has no property to be enforced, or the property of the person subject to enforcement is objectively impossible to dispose of, and the case cannot be enforced even if the enforcing court exhausts all means. The failure to enforce such cases is not due to the failure of the people's courts to enforce the law, but to the loss of solvency of the person subject to enforcement. >>>More

6 answers2024-02-08

Whether the mobile phone has a signal (of course, you can't send text messages without a signal, check whether the SMS storage is full if there is a signal, and delete it when it is full). >>>More

16 answers2024-02-08

string sqlstring = insert into table value;

sqlcommand slqcom = new sqlcommand(sqlstring, database connection object); >>>More