How to clean up session stored object data after session time out in JSF - jsf-1.2

I have a scenario in JSF. Where I need to clean up the folders cleared in that session at the end of the session ? how to handle this ?
Can anyone have any better solution ? Appreciate for your help.
~Shyam

Related

End a session remotely MVC 4

I found something to help me get a list of the active sessions from List all active ASP.NET Sessions.
What I now need to do, if possible, is be able to end any of the sessions from this list inside my application. The purpose of this is for user support, I don't have access to the IIS server hosting the app so I can't just jump on there to end sessions. Can anyone help with this?
You can call the Abandon method on the session, this will cause the End event to rise.
Check it out it here.

What is exact event(global.asax) to clear cache in asp.net

Im working on asp.net website.
In some pages I'm saving the datatable into chache as
cache["dt"]=dt;
and using whereever I want in that page by fetching from chache.
I'm thinking that whenever session close I want to clear session in session_end event of global.asax file.
as cache["dt"]=null;
What is the better location to close either application_end or session end.
If I close in session_end will it affect to another user?
Please provide me clear helpful info regarding this.
Thanks
Since you are putting the datatable in Cache, meaning, that it's shared by all the users, then there's no right place/need to do this, since the only time when it actually needs to be removed is when the application ends and at that point all resources are freed; your application is no longer running.
Perhaps what you should/meant to do was to put the datatable in Session. If that is what you want, then you could remove it OnSession_End in Global.asax but know that SessionEnd is not guaranteed to fire. You can also do Session.Abandon() when the user logs out, which will clear all session objects.
I think you misunderstood the concept between Application Data, Session Data, and Cache. These three of them all different things.
Application Data/State stores the information available in application scope, i.e. all session/user can access these data.
Session Data store info for the current session data. The duration of the session can be specified in the configuration files.
Cache stores frequently used data. And this data may be costly to regenerate every time.
In your case, since you are using cache, I assume that this cache stores some frequently used data. Ideally, this cache should always be valid, as long as the information does not changes.
As such, my recommendations is to keep this cache value as long as possible.

SessionCookies n asp.net

I am new to ASP.Net i dont understand the concept of sessioncookies
What is a sessioncookie,what are the advantages of sessioncookie
whats is sessioncookie is all about,
how to create a sessioncookie,
how to retreive values from sessioncookies,
how to store values in sessioncookies.
i searched in net but i dont get clear idea about the sessioncookie concept can anyone pls clarify whats is sessioncookies and its concepts and provide some code samples if possible.
Thanks
You can use the ASP.NET Session State to store information over multiple page requests. On MSDN, there's a nice introduction to the topic:
ASP.NET Session State Overview
The session cookie is used to associate the user's browser session with the session state object of ASP.NET. It's basically a implementation detail that you (usually) don't need to worry about: Use the Session object and let ASP.NET worry about setting/retrieving and managing the associated cookie.
Take a look at this:
http://www.codeproject.com/KB/aspnet/ExploringSession.aspx

How to get Session Data with out having HttpContext.Current, by SessionID

I am searching to find a way to read and write on session data but with out having the HttpContext. Current.
Why I won to do that ? because I wish to make some action with the user Session after the page have been close and unloaded.
For example, a user load and see a page, then I create a thread to make some action and let user go. Inside this thread I like to read the session data, but in this case HttpContext . Current is not exist any more.
So is there a way to read Session Data knowing just the session id.
I store my session inside an SQL server, and I see them. its there on table ASPStateTempSessions :)
How can I read them "offline" and manipulate them ?
Thank you in advanced.,
Still not quite clear why you might want to do that but you might not actually need to do it on Session_End(). At that point, it may be too late for you to work with the session data anyway (I've read some articles before about this). What might be a better solution is to actually attempt to work on the session data when your application actually has the context.
For example:
There's nothing to stop your application creating an asynchronous request on a new thread in the background (or even a different application, such as a Windows Service, for instance) when the specific session variable that you want is updated or has been set. This way, your application will be able to access the current HttpContext as well as all of the session data.
Not sure if this helps, but it was worth a shot ;)
Richard.
I may be a little late but...
Today I found about the:
System.Web.HttpRuntime.Cache
I know is not the same that a session but I think it's much better alternative that db.
Regards.

ASP.NET mixed windows/forms authentication problem with session objects

Weird problem here, we're running a few mixed environment web applications, that use Windows or Forms authentication depending on where the user comes from.
I'm curious how everyone else might be handling expired sessions to avoid the errors you would get from someone leaving an idle session open for too long and then trying to resume work, mainly looking for best practices on the subject.
Any suggestions or opinions would be greatly appreciated.
Thanks,
I'm not sure how your authentication method affects session timeouts, the mechanism they use to get in shouldn't affect how long they can stay in.
Generally speaking, if someone does have an expired session, you can add code to check to see if their session is active. If it isn't, just redirect them to a login page, or display some other friendly text.
Basically something like:
if (Session.IsNewSession)
Response.Redirect("login.aspx");
Don't store unnecessary information on the session.
If you are storing something you can reload, have the appropriate code that will reload it if it wasn't found in the session
Consider if some processes are meant to be handled in long periods of time, in which case save intermediate info to the database.
If the user is doing a process that uses the session, and the data is missing, take them to step 1 (not much you can do about it, if you don't have the info elsewhere).

Resources