Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Perdita Sessione

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2011
    Messaggi
    2

    Perdita Sessione

    Buongiorno a tutti. Sono nuovo di qui, tuttavia seguo il forum e il vostro sito da anni ormai, siete ovviamente un faro nella notte per chi si accinge alla programmazione.

    Dopo aver cercato in lungo e in largo per trovare una soluzione a questo problema, ho deciso di rivolgermi a voi, anche perché la soluzione la ho, ma non so come implementarla.

    Nel mio sito riscontro un problema che a quanto pare non tutti riscontrano, o sembrano averlo superato senza problemi; io tuttavia non mi raccapezzo...

    Succede, in pratica, che quando si fa un doppio click su un link (succede con qualsiasi tipo di azione eseguita molto velocemente, come refresh veloci della pagina, o click veloci su due link diversi), il sistema non riconosce più l'id di sessione e torna alla homepage. La stessa cosa capita quando avvengono rallentamenti sul sito per qualsivoglia ragione.

    Ora, premettendo che il codice è a mio parere corretto, perché tutto funziona normalmente, tranne in questi casi, e che all'inizio di ogni pagina vi è il session_start(); e il session_regenerate_id(TRUE); , cercando qua e là mi sono imbattuto in un commento di un tizio in una pagina della documentazione di PHP, in particolare, questa -> http://php.net/manual/en/features.cookies.php

    Il commento è il seguente:
    we got some complaints about legitimate users getting logged out without reasons. Turns out the problem was not tentative highjacking, it was either:

    A- Users double click on links or make 2 clicks very fast. The same key is sent for the 2 clicks because the new key from the first click didn't get to the browser on time for the second one but the session on the server did trash the key for the new one. Thus, the second click causes a termination of the session. (install the LiveHttpHeaders extension on firefox and look at the headers sent when you click twice very fast, you'll see the same cookie sent on both and the new cookie getting back from the server too late).

    B- For any given reason, the server experiences a slow down and the response with the new key (which has replaced the old one on the server) is not returned to the browser fast enough. The user gets tired of waiting and clicks somewhere else. He gets logged out because this second click send the old key which won't match the one you have on your server.

    Our solution was to set up a grace period where the old key was still valid (the current key and the previous key were both kept at all times, we used 15 seconds as a grace period where the old key could still be used). This has the drawback of increasing the window of time for a person to highjack the session but if you tie the validity of the old key to an IP address and/or user agent string, you still get pretty good session security with very very few undesired session termination.
    In poche parole, per chi si secca a leggere o non capisce bene la lingua, questo tizio ha avuto il mio stesso problema, e ha risolto dando un "grace period", come lo chiama lui, di 15 secondi alla key di sessione, nei quali sia quella nuova che quella vecchia sono valide per la sessione, e questa dunque non viene terminata.

    La mia domanda è: come faccio a dare questo "grace period" alla sessione?

    Grazie per l'attenzione =)

  2. #2
    Utente di HTML.it
    Registrato dal
    Nov 2011
    Messaggi
    2
    Up...?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.