mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-05 21:06:24 -07:00
Manage cookies expire in one month instead of two hours for convenience
This commit is contained in:
parent
e640002591
commit
3de5490b21
3 changed files with 5 additions and 5 deletions
|
@ -8,6 +8,7 @@ This is just a very preliminary roadmap to map out what I plan to focus on with
|
|||
* Improve posting stability (done)
|
||||
* Add management functions to make things simpler
|
||||
* Add some kind of database schema to handle any possible changes in the database structure with new versions (if there are any)
|
||||
* Add PostgreSQL (and possibly SQLite) support
|
||||
* Add functionality to aid new admins in transferring boards from other imageboard systems (TinyBoard, Kusaba, etc) to Gochan. This would largely be a database issue (see above)
|
||||
|
||||
2.x
|
||||
|
|
|
@ -143,11 +143,10 @@ func createSession(key string, username string, password string, request *http.R
|
|||
modLog.Print("Failed login (password mismatch) from " + request.RemoteAddr + " at " + getSQLDateTime())
|
||||
return 1
|
||||
} else {
|
||||
// successful login
|
||||
cookie := &http.Cookie{Name: "sessiondata", Value: key, Path: "/", Domain: domain, RawExpires: getSpecificSQLDateTime(time.Now().Add(time.Duration(time.Hour * 2))), MaxAge: 7200}
|
||||
// cookie := &http.Cookie{Name: "sessiondata", Value: key, Path: "/", Domain: config.Domain, RawExpires: getSpecificSQLDateTime(time.Now().Add(time.Duration(time.Hour*2))),MaxAge: 7200}
|
||||
// successful login, add cookie that expires in one month
|
||||
cookie := &http.Cookie{Name: "sessiondata", Value: key, Path: "/", Domain: domain, Expires: time.Now().Add(time.Duration(time.Hour * 730))}
|
||||
http.SetCookie(*writer, cookie)
|
||||
_, err := db.Exec("INSERT INTO `" + config.DBprefix + "sessions` (`key`, `data`, `expires`) VALUES('" + key + "','" + username + "', '" + getSpecificSQLDateTime(time.Now().Add(time.Duration(time.Hour*2))) + "');")
|
||||
_, err := db.Exec("INSERT INTO `" + config.DBprefix + "sessions` (`key`, `data`, `expires`) VALUES('" + key + "','" + username + "', '" + getSpecificSQLDateTime(time.Now().Add(time.Duration(time.Hour*730))) + "')")
|
||||
if err != nil {
|
||||
errorLog.Print(err.Error())
|
||||
return 2
|
||||
|
@ -159,7 +158,6 @@ func createSession(key string, username string, password string, request *http.R
|
|||
return 0
|
||||
}
|
||||
}
|
||||
return 2
|
||||
}
|
||||
|
||||
var manage_functions = map[string]ManageFunction{
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue