Unset session after some time

前端 未结 2 1560
逝去的感伤
逝去的感伤 2021-02-10 04:16

I am building a online ticket booking site . In this I am doing the following things : The user searches the bus with their seat numbers . The database is updated with the seat

2条回答
  •  独厮守ぢ
    2021-02-10 04:51

    Standard PHP sessions are stored in files. You could implement a simple shell script to find any session file which hasn't been touched in 10 minutes:

    find /path/to/session/dir/* -mmin -10
    

    grep can be used to find the session files which have a final_ticket_book='N' value stored in them:

    grep -l 's:17:"final_ticket_book";s:1:"N";'
    

    (the -l flags has grep spit out the names of the files which match).

    Combining the two gives you:

    find /path/to/session/dir -mmin -10|xargs grep -l 's:17:"final_ticket_book";s:1:"N";'|xargs rm -f
    

提交回复
热议问题