1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-22 07:50:18 +00:00

Add error to SessionExist interface

Implement changed interface for all default providers as well and change
tests accordingly
This commit is contained in:
Phillip Stagnet
2020-08-03 13:31:49 +02:00
parent 9e1346ef4d
commit 28e6b3b924
14 changed files with 109 additions and 48 deletions

View File

@ -164,13 +164,19 @@ func (mp *Provider) SessionRead(sid string) (session.Store, error) {
}
// SessionExist check mysql session exist
func (mp *Provider) SessionExist(sid string) bool {
func (mp *Provider) SessionExist(sid string) (bool, error) {
c := mp.connectInit()
defer c.Close()
row := c.QueryRow("select session_data from "+TableName+" where session_key=?", sid)
var sessiondata []byte
err := row.Scan(&sessiondata)
return err != sql.ErrNoRows
if err != nil {
if err == sql.ErrNoRows {
return false, nil
}
return false, err
}
return true, nil
}
// SessionRegenerate generate new sid for mysql session