• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Management

 
ash neet
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I have created a session for user who logs in. after the user logs out, the session is invalidated. i have given a link for "Home page" on the logout page. When the use logs out and clicks the home link, the user is redirected to home page. but even after logging out, the "welcome user" and "logout link" still remains on the home page. I tried to clear the cache by using -

<%
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>

but, no effect. the session is invalidated, I checked. what could be the reason? please help!!

regards,

Ashneet.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would caching have to do with removing elements from a page?
 
ash neet
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:What would caching have to do with removing elements from a page?


I thought so. So how do I remove the elements?

I have used -
<%
username = session.getAttribute("username");
%>
<%
if(username!=null)
{
%>
welcome <%=username%>, logout
<%
}
%>
 
Aniruddh Joshi
Ranch Hand
Posts: 275
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this :
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, you should not be using scriptlets. Java code in a JSP has been discredited for over 9 years now, and their use at this point is irresponsible.

Using the JSTL and EL, the scenario could be as follows:

  • Let's say that when the user logins in, you place a scoed varibale named user in the session.
  • For logging out, you simple remove the variable. You can invalidate the session, but it's really not necessary.

  • On pages, you can easily check to see if the scoped variable is in the session with:
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic