Giter Site home page Giter Site logo

session's People

Contributors

dependabot[bot] avatar fenny avatar github-actions[bot] avatar hugmouse avatar klipitkas avatar renanbastos93 avatar thomasvvugt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

session's Issues

I cannot get value set in the redis store

I am working with fiber golang framework. I can't figure out why I cannot get the value set in the store(Redis in this case) from another request or within. Below is the code:

sessionProvider := redis.New(redis.Config{
    KeyPrefix:   "session",
    Addr:        "127.0.0.1:6379",
    PoolSize:    8,
    IdleTimeout: 30 * time.Second,
})
sessions := session.New(session.Config{
    Provider: sessionProvider,
})

// sample routes for testing session
app.Get("/testing1", func(c *fiber.Ctx) {
    store := sessions.Get(c)
    //    set value to the session store
    store.Set("name", "King Windrol")
    store.Save()
})
app.Get("/testing2", func(c *fiber.Ctx) {
    store := sessions.Get(c)
    c.Send(store.Get("name"))
})

I've tried to get it from within the same request, it seems to work just before calling store.Save() but not working after! it just returns nil

Session Destroy and Regenerate not working

I can't seem to get sessions to be destroyed or regenerated. I've tried both memcache and mysql but store.Destroy() and store.Regenerate() aren't doing anything that I can tell. Am I doing something wrong?

Mac OSX        : 10.15.4
Fiber          : v1.12.0
Fiber Session  : v1.2.1

session not stored?

I've tried use session to store some data. But it seems data are not stored among different requests. Is it implementation issue or usage issue?

A simple use case is:

package main
import (
    "github.com/gofiber/fiber"
    "github.com/gofiber/session"
    "github.com/gofiber/session/provider/sqlite3"
)

func main(){
    app := fiber.New()

    provider := sqlite3.New(sqlite3.Config{
        DBPath: "session.db",
        TableName: "session",
    })
    sessions := session.New(session.Config{
        Provider: provider,
    })

    app.Get("/get", func(c *fiber.Ctx) {
        store := sessions.Get(c)
        defer store.Save()
        id,ok := store.Get("id").(int)
        if ok {
            c.Send("id=",id)
            store.Set("id",id+1)
        }else{
            c.Send("id empty, in session:",store.ID())
            store.Set("id",1)
        }
    })

    app.Listen(8060)
}

And when use browser to reload "http://url/get", I expect the id to be increment while session ID keeps the same.

Actual result is id always empty, and session ID keeps the same.

I also tried redis provider, the result is the same.

Am I use the API correctly? Or is there anything wrong with the implementation?

Questions for session implementation

Hi Fenny, I want to ask you some questions about session.

  1. Will you wrap fasthttp/session and follow the pattern it's using?
  2. Is this package going to be used as middleware?

I implemented some part of code wrapping that and tested using Postgres and built Save and Get methods to use. If it's same way you are going, I will make PR and wish this helps your hardworking on fiber packages.

store.Destroy not real working for v2.0.2

Dear Team:

First all According to old version gofiber/session(v1.2.5) "Destroy" function is working fine. But when we upgrade to v2.0.2, "Destroy" function has been change, and if we still follow Example from README.md "Destroy" function will not working to "delete storage + cookie".

In our research, we find out the issue maybe is "Destroy" function itself has not been "Reset" dict data any more. So when we call "Save" function the dict data has been store back.

So we are very confused about it, are we missing something? Or this issue will be fix?

B.R & Tks.
Gordon

[sqlite3] Panic: runtime error

For some reason, the new version of Session panics with sqlite3 driver, although the example code has not changed.

Steps to reproduce

  1. Copy-n-paste the code below
  2. go run main.go 2 times

Example code

package main

import (
	"github.com/gofiber/fiber"
	"github.com/gofiber/session"
	"github.com/gofiber/session/provider/sqlite3"
)

func main() {
	app := fiber.New()

	provider := sqlite3.New(sqlite3.Config{
	  DBPath:     "test.db",
	  TableName:  "session",
	})

	sessions := session.New(session.Config{
		Provider: provider,
	})

	app.Get("/", func(c *fiber.Ctx) {
		store := sessions.Get(c)
		defer store.Save()
		c.Send(store.ID())
	})

	app.Listen(3001)
}

Error

2020/07/21 00:31:42 session error: session: sqlite3 index last_active already exists; provider: sqlite3;
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x40 pc=0x13721e5]

goroutine 1 [running]:
github.com/fasthttp/session/v2/providers/sqlite3.(*Provider).NeedGC(0x0, 0xc0000ce820)
        <autogenerated>:1 +0x5
github.com/fasthttp/session/v2.(*Session).SetProvider(0xc000582000, 0x1637700, 0x0, 0x1, 0x1)
        C:/Users/mysh/go/pkg/mod/github.com/fasthttp/session/[email protected]/session.go:64 +0x51
github.com/gofiber/session.New(0xc0004a7f10, 0x1, 0x1, 0x0)
        C:/Users/mysh/go/pkg/mod/github.com/gofiber/[email protected]/session.go:148 +0x533
main.main()
        C:/Users/mysh/go/src/sqliteSessionsBug/main.go:17 +0x135
exit status 2

Error (image)

image

Session data seems to not be saved between requests

Hi,

It seems my session is not being saved, question is am I doing this right? I am not entirely sure so here's a little more context.
I am implementing a simple session-based login like this:

storage := sqlite3.New()
store := session.New(session.Config{
  Storage: storage,
})

then I save it

sess.Set("email", "[email protected]")
defer sess.Save()

and then I try to read the value:

email := sess.Get("email")
log.Println(email)
log.Println(sess.Keys())

So my first question is: am I doing it right?

How to save reference to mongo client in session?

How would i go about saving a reference to the mongo connection in essence caching the connection and not having to make the call every time?

client, err := getMongoDbConnection(credentials)
store.Set("mongoRef", client)
err = store.Save()
fmt.Println(store.Get("mongoRef")
fmt.Println(err)

>>>>

<nil>
msgp: type "mongo.Client" not supported at D/2/Value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.