spring-projects / spring-projects/spring-session

Session attribute not persisting which is setting at HttpSessionListener using Spring Session Data Redis

Open
#1,788 7 comments 1 reaction 1 assignee View on GitHub

Nobody has claimed this yet.

status: feedback-provided type: bug
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

Session attributes are missing/not able to fetch which are setting at HttpSessionListener

I want to set some attributes to session when session is created using HttpSessionListener, and I want to validate that attribute in the next level.

To Reproduce
After installing redis just install on localhost and default port, build and run the project shared on github.

Expected behavior
What ever attributes I am setting on session creation HttpSessionListener

 public void sessionCreated(HttpSessionEvent httpSessionEvent){
        HttpSession httpSession = httpSessionEvent.getSession();
       System.out.println("inside listner class ====");
        httpSession.setAttribute("testKey","testValue");

       System.out.println("test value inside listner===>"+httpSession.getAttribute("testKey"));
    }

here I am able to fetch the session atrribute testKey, but after this when flow goes to servlet, I am not getting the attribute
Sample

I have attached the code in this link

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.