action_singout.go 512 B

12345678910111213141516171819202122232425262728
  1. package actions
  2. import (
  3. //"database/sql"
  4. //_ "github.com/go-sql-driver/mysql"
  5. //utils "golang-fave/engine/wrapper/utils"
  6. )
  7. func (this *Action) Action_singout() {
  8. if err := this.use_database(); err != nil {
  9. this.msg_error(err.Error())
  10. return
  11. } else {
  12. defer this.db.Close()
  13. }
  14. if err := this.load_session_user(); err != nil {
  15. this.msg_error(err.Error())
  16. return
  17. }
  18. // Set to zero
  19. this.wrapper.Session.SetInt("UserId", 0)
  20. // Reload current page
  21. this.write(`window.location.reload(false);`)
  22. }