Does Disabling Cookies End a Session?

I am creating a web application, so far I have implemented login and registration. The user can register and then log in to the web application. Everything is working fine. What I am doing is when the user clicks the button Login, the servlet is called, where I check the credentials are correct, if checked, then Save isLoggedInto HttpSessionand redirect it to Home Page.

LoginServlet.java

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
    boolean isValidated = false;
    ... // Service Layer is invoked here and checks for user validation

    // Assume isValidated to be true
    if(isValidated){
        HttpSession session = request.getSession();
        session.setAttribute("isLoggedIn", Boolean.valueOf(true));
        ...
        // redirected to /home
    }else{
        // redirected to /login?invalid
    }
}

HomeController.java

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{

    HttpSession session = request.getSession();
    Boolean isLoggedIn = (Boolean) session.getAttribute("isLoggedIn");
    if(isLoggedIn != null && isLoggedIn){
        ...
        // Service Layer is invoked to fetch `Home Page Data`
    }else{
        // redirected to /login?expired
    }
}

Suddenly I had a strange problem. If I disable cookies for localhost with FireBug, I can no longer log in. Regardless of entering the correct username or password every time I get redirected to /login?expired.

, Cookies , , session , Cookies .

Cookies - Spring -MVC, ​​ .

+4
4

cookie , cookie JSESSIONID.

cookie , GET (.. &JSESSIONID=1223456fds URL-).

URL , . , .

, (, Spring MVC Thymeleaf), . , URL- response.encodeURL(), .

+1

. Http - . , , (), . cookie , . url (jsessionId), cookie . URL-, response.encodeURL() URL-.

+3

, , Cookie , , , . , cookie , , cookie .

For more information you can refer to this link. Press here

+3
source

When we manage the session using the mechanism HttpSessionso that the jsessionid time is stored in the browser cookie. Therefore, when you delete cookies from the browser or disable cookies at a time when jsessionid information is not sent to the server, and the time server processes this request from a new session.

0
source

All Articles