Click here to Skip to main content
15,891,184 members
Everything / Session

Session

session

Great Reads

by Sujeet Bhujbal
In this article, I will tell you how to create a cross-browser session expiration popup box using jQuery easily
by KianTing
MuleSoft provides a good structure of documents for developers to learn about its types of variable and properties, but as we all know reading and understanding the concepts is good, but you never beat the act of actually rolling up your sleeves and practicing it in a lab exercise. Learning from exp
by ASP.NET Community
ASP.NET Session state provides a place to store values that will persist across page requests.  Values stored in Session are stored on the server
by ASP.NET Community
ASP.NET offers a number of places to store state, both on the client and server. However, sometimes it's difficult to decide where you should put

Latest Articles

by Member 10262330
I developed this DLL to have a more powerful utility and to simplify SP and query.
by Sujeet Bhujbal
In this article, I will tell you how to create a cross-browser session expiration popup box using jQuery easily
by KianTing
MuleSoft provides a good structure of documents for developers to learn about its types of variable and properties, but as we all know reading and understanding the concepts is good, but you never beat the act of actually rolling up your sleeves and practicing it in a lab exercise. Learning from exp
by Fiyaz Hasan
Creating local server farm with IIS to test out Redis session storing functionality in a ASP.NET web application.

All Articles

Sort by Score

Session 

10 Mar 2017 by Sujeet Bhujbal
 In this article, I will tell you how to create a cross-browser session expiration popup box using jQuery easily
28 Apr 2011 by Albin Abel
If you know about Personalization you can very well to store and retrieve user specific informations instead of session. However those objects needs to be serializable. This is an alternate suggestion. If you already know about personalization in .Net i don't need to write more on it :)
11 May 2011 by Wonde Tadesse
First of all your Session["MenuValue"] is not changed once you select the combobox. There are two solution for your problem.1. If you don't want to change your Session variable then change your code like this and keep the rest of your code.protected void Page_Load(object sender,...
7 Aug 2011 by Not Active
Please view the ASP.NET page life cycle. The session has been started before the login page is processed. Seems logical right? How could you access a Session variable without the session having been started already?Redirect the user after they have successfully logged in.Also, this check...
28 Feb 2012 by Shahin Khorshidnia
Hello,I know 2 ways:1. use GUID as Session and store it in database as a codeFor example:Select * From Question Where Code = @UserID2. After registering user, before starting the exam, store user's information in database with an ID then get the ID (How?...
7 Jun 2012 by codeBegin
Session Time Out is 20 minutes by default. The value is affected in a number of settings including Application Pool, ASP, ASP.NET Session State, CookieTimeout.Please follow instruction below to configure Session Time Out on IISOpen IIS ManagerApplication Pool -> Advanced Settings...
2 Feb 2013 by Sandeep Mewara
Change your code to handle the error case as:protected void Page_Load(object sender, EventArgs e){ if(Session["UserName"] != null) lblUser.Text = Session["UserName"].ToString(); else Response.Redirect("SessionTimeoutMessagePage.aspx");}
4 Jul 2013 by OriginalGriff
Not really - there is a huge difference between the two: one is server side, and the other is client side. That means two things:1) Cookies are persistent - they can survive beyond the limits of the current session. So the user can turn his computer off, come back tomorrow and the cookies are...
8 Sep 2014 by Raul Iloc
1.For session expiration, you could do this by managing Session_End event in MvcApplication class from your Global.asax.cs, like in the next example:protected void Session_End(object sender, EventArgs e) { SiteSession siteSession = (Session["SiteSession"] == null ? null :...
26 Jul 2019 by Richard Deeming
Looks like you're missing a semi-colon after your call to session_start[^]. You've also added a new block for no apparent reason, which almost makes the following code look like it's part of a function called session_start, even though it's not. And as Richard MacCutchan pointed out, you're...
6 Jan 2011 by Orcun Iyigun
Maybe reading these articles helps you;http://www.primaryobjects.com/CMS/Article86.aspx[^]For your first doubt look at this;http://forums.asp.net/p/1104278/1685530.aspx[^]for the redirect problem ;http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23397441.html[^]
14 Jan 2011 by Ashish Tyagi 40
As Espen Harlinn told you can put another similar type list for only 15 itemsor if you show your code than it will help us to help you..
26 Feb 2011 by _Ashish
You cannot directly access the Session variable in a Thread. Session is associated with HttpContext.Current object. When a Http request is under process a HttpContext.Current is instantiated and thus the HttpContext.Current.Session is instantiated. These objects gets out of scope when a http...
28 Apr 2011 by wooga111
Hello All,Here is my scenario:I am using VS2010 and have a ASP.NET web application. On my page I am using a WebUserControl that uses a modelpopupextender to allow a user to select contacts from a list. All of this is contained in a asp.net formview.After a user selects some contacts...
2 Jan 2012 by OriginalGriff
You really shouldn't be holding a session open for that long - each session uses precious memory on the server. If you look at MSDN Session.Timeout[^] it does say that it should not be set higher than 20 minutes. If you need data retained for a long period, you should really use cookies instead.
2 Jan 2012 by NandaKumer
check these blogshttp://bytes.com/topic/asp-net/answers/346186-asp-net-session-timeout-problem[^]http://www.primaryobjects.com/cms/article86.aspx[^]--NDK
9 Jul 2012 by OriginalGriff
The session will expire after a preset time - if you are storing login information in the session, then at that point the user will be logged out (this time is reset each time the user posts back to the site)You can change this timeout timer, but you should not extend it from it's default of...
26 Sep 2012 by Stephen Hewison
Hi,I'm interested in finding out user experiences with custom session state providers for ASP.Net.The requirement is to transparently change the session state provider for our ASP.Net applications so there is no stickiness/affinity between the users session state and a specific web...
7 Jul 2013 by Shubhashish_Mandal
Do the following steps..1. First remove the onclick event from login/logout button.2. Set the form-action with the url pattern . I don't know what is the urlpattern for your app ("main/Serveletr" or "login").
23 Dec 2013 by JoCodes
Yes . You can set the session time explicitly for user types Try protected void SetSession(string userType){ if (UserType == "admin") { Session.Timeout = 20; } else { Session.Timeout = 10; }}Hope this helps...
31 Oct 2014 by kedar001
Sessions are stored in server memory, and sessions may/maynot use cookies to store something in the browser. Session is basically to identify a user in his security context. The web application uses session to identify whether the user is authenticated.. etc.So use session if you want to store...
21 Nov 2014 by Afzaal Ahmad Zeeshan
You would be using this code instead of that one, List cart = new List();// Add it to the listcart.Add(Convert.ToString(Session["UserAuthentication"]));This way you can add a new element to the generic list you're having. You donot convert a...
24 Nov 2014 by OriginalGriff
Why would you expect it to convert a List of strigns to a string for you?If you wrote this:List list = new List();string s = (string) list;You would expect an error woudln;t you?So when you do this: var selectedProducts = GridView1.Rows.Cast() ...
7 Feb 2017 by KianTing
MuleSoft provides a good structure of documents for developers to learn about its types of variable and properties, but as we all know reading and understanding the concepts is good, but you never beat the act of actually rolling up your sleeves and practicing it in a lab exercise. Learning from exp
18 Apr 2018 by WAMCE
I am working on one MVC application, where there is separate WEB API project also. Now I want to implement update email functionality based on OTP verification from mobile via WEB API. Web API is stateless but still, I want to implement SESSION in my code so that I can access OTP value in...
28 Apr 2010 by elad2109
HiDoes someone know if if i run PSEXEC (or WMI) N times in the same program -does it open N new sessions?or does it uses the same session over and over again?
1 Jan 2011 by Shani Natav
You have two options:1) Session In Process, each server keeps the session state in the ASP.NET Process) with Session Affinity - All requests with the same session ID are handled by the same server.2) Session out of process - Session is handled by a session server, could be sql server or...
19 Jan 2011 by #realJSOP
Couldn't you just save that data in the database into a LastSession table?
15 Feb 2011 by Vivek Krishnamurthy
You can try with adding SerializableAttribute on the objects you are storing in session. If this does not solve you can implement ISerializable interface. Objects stored in session state must be serializable if the mode is SQL Server.
23 Feb 2011 by AndyASPVB
HiI am creating a web application that will be running on an infrastructure which will utilise a number of web servers, web gardens and a load balancer.As the application is using Sessions, and that our application is using Oracle as the database, we would like to use the database to...
20 Apr 2011 by meyssamhf
change the session name, Use MyUserID or any things instead of UserID.
24 Jun 2011 by Dylan Morley
Please see my answer recently about a similar Session issueRedirect to login page when the Session is Expired.[^]The problem with your code is that it's all client side javascript - you haven't tested for the session anywhere, you'd need to call back to the server in order to access...
7 Aug 2011 by no_-_namee
Hi,In the application I develop, I want to start session when user log in and to end when user log out or session timeouts.I added the following code in web.config file, I controlled the user login at login.aspx;SqlConnection...
23 Aug 2011 by Djamanet
How can i make my session state time out persits for more than one day?
13 Jan 2012 by NandaKumer
check these blogshttp://forums.asp.net/t/1758962.aspx/1?StateServer+session+mode+in+shared+hosting+server[^]http://stackoverflow.com/questions/1447175/sqlserver-vs-stateserver-for-asp-net-session-state-performance[^]--NDK
30 Jan 2012 by Sergey Alexandrovich Kryukov
Those browser are not yours. Maybe you want to patch them? That can be difficult: IE is all closed source, and Chrome is at least partially proprietary (http://en.wikipedia.org/wiki/Google_Chrome[^]).Are you getting the picture?—SA
20 Mar 2012 by Not Active
Remember the web is a stateless beast. Once the page is rendered to the browser it has no connection to the server, which doesn't know if the user is still viewing the page, has navigated away or gone to lunch. You would need some type of polling to occasionally contact the server to check the...
10 May 2012 by Sandeep Mewara
You can enable or disable session at page level too. Using Page[^] property EnableSessionState. Have a look at this article: How To Disable ASP Session State in ASP.NET[^]
7 Jun 2012 by abhinavvijay
protected void Session_End(Object sender, EventArgs e){ DirectoryInfo d = new DirectoryInfo(session["sFileName"].ToString()); foreach (FileInfo f in d.GetFiles()) { if (f.CreationTime.AddHours(1)
3 Jul 2012 by Prasad_Kulkarni
Refer similar QA:How to avoid multi user signin using same credential in asp.net? How to clear session on all browser close? please help me[^]Prevent multiple login in asp.net[^]..and more similar answers on CodeProject[^]
24 Jul 2012 by Sandeep Mewara
Display frequent visited linksOne of the ways used to do it: Store the last visited links in Cookies and use them to find the last visited links.Refer: MSDN: ASP.NET Cookies Overview[^]
28 Jul 2012 by StianSandberg
You never set the session value. To set a session value:Session["name"] = value;
26 Aug 2012 by Mayur2258
Hi Everyone,I am creating a small website which i am gonna placed on Local shared drive.I have Created a Simple Login Page using Javascript Code as Follow:function check(form){/*the following code checkes whether the entered userid and password are...
26 Aug 2012 by enhzflep
Gday mate.Sounds like you're just doing a home-project, type thing - i.e all machines in same building/residence - not something to be accessed from the outside world.In either case, it's really something that you need a webserver(software) for. That way, you have the file 'home.html' (or...
25 Sep 2012 by Meet Raval
Try this.. You can add mode="InProc" cookieless="false" in SessionState.You can also write the following solution in .cs file Session.Timeout =...
1 Nov 2012 by onelopez
If you store the session in process memory then you won't be able to restore expired session; however if you do have it stored in the database, then you can just ignore the expired time stamp and extend it some more. Here's an interesting article on session storage Exploring Session ASP.NET
10 Jan 2013 by OriginalGriff
You can increase the timeout, but you shouldn't have to.To increase it, see here: http://msdn.microsoft.com/en-us/library/h6bb9cz9(vs.80).aspx[^]But you should cope with the session timing out gracefully, by checking, or by using a try...catch block.Oh, and by the way, never read the date...
18 Jan 2013 by Abhinav S
GridView1.SelectedRow.FindCont...
8 Feb 2013 by Aarti Meswania
The Session property provides programmatic access to the properties and methods of the System.Web.SessionState.HttpSessionState class. Because ASP.NET pages contain a default reference to the System.Web namespace (which contains the HttpContext class), you can reference the members of...
26 Feb 2013 by OriginalGriff
Any data you keep in the Session variables does not leave the server, so it is secure from a client point of view - it is not transmitted across the internet provided your code does not do anything like that with it.Does that make it secure? Depends on your definition of "secure" and how...
19 Mar 2013 by Prasad Khandekar
Hello Rahul,Go through this[^] article available on this site itself. It should help you in fixing your problem. Regards,
27 Mar 2013 by AspDotNetDev
I'm still not too clear on how the pieces fit together, but try this:If Session("guid") Is Nothing Then Session("guid") = Guid.NewGuid().ToString()End IfThat way, the GUID will only be placed in session if it doesn't already exist.
22 May 2013 by Mahesh Bailwal
Below is the sample code of one the way achieving this, sample code will just to give you an idea. Here idle time for testing is 3 second (you can change that). This sample got one text box if user does not click on it with 3 sec interval user will be logged out.
9 Jul 2013 by Rony Sur
I think its better not to use session for orders. Rather you can use database table to store order values. I know it will store a huge unwanted data. But you can set a cron job to remove the orders placed before 7 days. This process is more reliable and I used to use this technique in most of my...
5 Aug 2013 by Ankur\m/
Session is a server side technology. Client/Browser doesn't know anything about ASP.NET Session.I am assuming you get the details on client side using JavaScript code. You will need to post back the page and then save the details in the Session variable on the server side.
29 Aug 2013 by TheUltimateDebugger
Session In MVC[^]You can check the link..hope it will help..
11 Oct 2013 by ASP.NET Community
ASP.NET Session state provides a place to store values that will persist across page requests.  Values stored in Session are stored on the server
11 Oct 2013 by ASP.NET Community
ASP.NET offers a number of places to store state, both on the client and server. However, sometimes it's difficult to decide where you should put
16 Oct 2013 by codestar007
http://msdn.microsoft.com/en-us/library/ms178586.aspx[^]
27 Nov 2013 by Jitendra sondarva
I have two web application (Asp.net - VB) one in VS 2005 and another is in VS 2012 - Now I have to share session between these two applications. Session state actually maintain in VS 2005 (Old project) and both application are hosted on same IIS (7.0). When I access page from VS 2012 project I...
20 Dec 2013 by OriginalGriff
Um. Lets have a look at that code, shall we?If(!Session.IsNewSession){...}else{ if(Session["MyVariable"] !=null) //Here I am always returning null :( {... }}So, you only directly try to use the Session variables if this is a new Session? When teh variables will...
20 Dec 2013 by Peter Leow
You use the first one to create a session variable "username" to store $username the value of which come from a successful login operation.Then, the second one uses this session variable to check if a user has logged in or not at the beginning of every secured pages, say// Check if...
22 Dec 2013 by Er. Tushar Srivastava
Simple Answer is,If you have a login page and some user logged in. Now you want to store his information like username, fullname, age etc for the session, then you will have to store this data in the $_SESSION variable and the assignment operator '=' is used to assign the value of variable...
12 Feb 2014 by Peter Leow
change:echo " $_SESSION['id']" ; toecho $_SESSION['id'];
18 Feb 2014 by Ankur\m/
You could have found helpful links yourself by just typing 'session subdomain asp.net' on Google[^].Basically you will need to set domain to your HttpCookie in web.config.
26 Feb 2014 by footballpardeep
Is there any event which is fired when a value in the session is set.Example:On page: www.abc.aspx?param=one and having code: Session["data"]="some data1"; www.abc.aspx?param=two and having code: Session["data"]="some data2";I am searching for some event where i can change the...
26 Feb 2014 by Rana Zarour
I think you can use Page_Load event you can check your query string value and set your session
13 Mar 2014 by Aravindba
Hai what is meant by "unique session" ? if "Object reference not found" means some values is empty or cant retrieve from database or cant get value from session or anythin.....Pls post ur code and mention which line u get error,If u ask any question try to post ur what u did,simply...
27 Mar 2014 by Raul Iloc
I have manage the problem in a Code Project article but in the case of an ASP.NET MVC application, so for your case should be something similar. Here is the link: MVC Basic Site: Step 2 - Exceptions Management[^]You should look especially on the next chapter: "Manage Unhandled Exceptions".
31 Mar 2014 by Guruprasad.K.Basavaraju
Try Response.Redirect("View.aspx", false);I think the response.redirect ends the response. Response.End actually stops the execution of the page wherever it is using a ThreadAbortException. What happens really here is that the session token gets lost in the...
10 Apr 2014 by Nirav Prabtani
By default our websites session timeout is 20 mins after that session will gets expire suppose if we want to set our custom timeout in our applications we can set it in different ways (web.config, global.asax and in IIS)Check below methods to set session timeout in web.config, global.asax...
27 Apr 2014 by Yogesh Kumar Tyagi
hello, i am create a Property for session variable public static string CurrentFolderPath { get { return System.Web.HttpContext.Current.Session["FolderPath"].ToString(); } set { System.Web.HttpContext.Current.Session["FolderPath"] = value; } }...
27 Apr 2014 by DamithSL
you may need to add null check in getter of the property public static string CurrentFolderPath{ get { if (HttpContext.Current.Session["FolderPath"] == null) return string.Empty; else return...
4 Jul 2014 by sankarsan parida
// In this example, the session parameter "username" is set // after the employee successfully logs in.SessionParameter username = new SessionParameter();empid.Name = "username";empid.Type = TypeCode.String;empid.SessionField = "username";Get moredetails msdn[^]
4 Aug 2014 by danigeraleddin
I'm invoking in the ItemDataBound event of repeater control an object that uses the value of the user's session, but I get error, it seems that the object can not to be created and when I use this same object in subsequent events at load, I haven't problem, I need to know when to start the...
20 Aug 2014 by Prakriti Goyal
Hello,ViewState can only save data during postback of your page. Here, what you are doing is transferring it to other page and hence viewstate loses data. While Session maintains data for current user and that is why it does not loses data.For...
21 Aug 2014 by Raul Iloc
1.You have some errors in your code: i)first problem is that you have 6 columns but you are trying to get the foodID from the 8th one, and should be from 6th position like: GridView1.SelectedRow.Cells[5].Text or better you could use the Keys property of your GridViewDeleteEventArgs parameter....
22 Oct 2014 by IpsitaMishra
please check the linkHow to end user session when browser closed[^]Hope it will help you.
9 Dec 2014 by Zoltán Zörgő
Yes, it is a good idea, as this one is lower level as form state or application state was in web forms. It is well bound with IIS (and the web standards also), and you have several possibilities to tailor it[^] to your needs. And by the way you have nothing else in the hand to make your...
29 Dec 2014 by Dinkar Tiwari
have a look on this link http://searchwindevelopment.techtarget.com/tip/Share-session-state-between-ASP-and-ASPNET-apps[^]
9 Jan 2015 by ssharma21
Hi Guys,I am working on a portal which has two option as links-1) high contrast color2) reset to defaultFor this I have made two css-- one for default colors and other for high contrast colors.I want when a user click on any option that option will work for all the pages till he...
25 Mar 2015 by Suvendu Shekhar Giri
You can do that by 1. Replacing the timeout value in web.confighere 40 means 40 minutes.Or2. In Session_Start method of Global.asax file, you can set the timeout propertySession.Timeout = "40";Update:If you want unlimited session then you may...
9 Apr 2015 by OriginalGriff
You should not extend the session - each user instance increases the memory usage on teh server, which can't be disposed of until the session ends. See MSDN: https://msdn.microsoft.com/en-us/library/ms525473(v=vs.90).aspx[^]And bear in mind that each time the client communicates with the...
4 May 2015 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Something like this...dt.DefaultView.Sort = "YourColumnName ASC"; // DESC for descending.
14 Jul 2015 by F-ES Sitecore
Things that are static only have one copy that is shared by everyone and your static constructor is only called once (the first time ShoppingCart is accessed). So basically the first person to use their cart has a cart created and store in their session, and that cart is then used by everyone...
2 Aug 2015 by DamithSL
try like below Dim dt As DataTable = Session("Grid_Details")dt.DefaultView.Sort = "PubDate"gv.DataSource =dt.DefaultView.ToTable()gv.DataBind()if you need to sort by Date you need to set column type as Date or DateTime for example dt.Columns.Add("pubdate",...
26 Jan 2016 by Dave Kreskowiak
How about reading the documentation on the load balancer?This site is about writing code, not product support on your load balancer.
18 Mar 2016 by F-ES Sitecore
Browser tabs are a client technology, your server and your code knows nothing about them. Sessions run off of cookies so if the browser uses the same cookies for the same site in different tabs then each tab will see the same session, there is nothing you can do about that, it is all down to...
17 May 2016 by Kornfeld Eliyahu Peter
First of all, IMHO it is not a good idea to use ASP.NET hosted WCF services, but you better choose ASMX...However if you choose to stick with WCF and you want it cooperate with ASP.NET, you have to take care a few things:1. Use HTTP binding (too)2. Adjust ASP.NET compatibility of the WCF...
25 Jun 2016 by phil.o
Session property of you CardexController instance is null, undoubtably.It's time for you to put a breakpoint on the line which initializes the controller, and press F5.The fact that the Session property expects some instance of an object which implements a given interface (I just...
19 Sep 2016 by Karthik_Mahalingam
Quote:Uncaught ReferenceError: getdata is not definedgetdata function is enclosed with jquery, remove it. $( function getdata(obj) { and remove ) at the end of the function.
3 Oct 2016 by OriginalGriff
Presumably, you've checked your existing code and web.config, and tried increasign teh timeout there: HttpSessionState.Timeout Property (System.Web.SessionState)[^]If that doesn't work, then you need to talk to your web hosting company: I know that some reduce it to five minutes and have set...
31 Jan 2018 by Prabhanjant
Try writing dtp.acceptChanges(); See if this works. Please mark this as answered if this solves your problem.
4 Apr 2018 by F-ES Sitecore
There is only one instance of a static variable that everyone shares so it's not suitable for storing this data. You need to store your data in the Session instead as that is intended for this very purpose. If you're having problems using the Session then post the relevant code and explain the...
24 Jul 2018 by Peter_in_2780
Your is the problem. You may not output ANY HTML before things that send headers (like cookies). The
12 Dec 2018 by OriginalGriff
Check that the definition of sLoginName is part of the page class definition, not in a subsidiary class, or a general class: public partial class MyPage: System.Web.UI.Page { public string sLoginName = string.Empty; protected void Page_Load(object sender, EventArgs e) { ...
1 Feb 2019 by MadMyche
Looks like the problem is that the UI portion of this is not accepting the Session Cookie from the WebAPI. When the API does not receive the Session Cookie from a client, the API will start a new session when it receives a request. What you will need to do then is to enable cookies in the UI...
10 Sep 2020 by W Balboos, GHB
I presume you have a database, somewhere, to access and test the original login. If you could add in php then you could store a uid/key pair in a $_SESSION variable. Check the UID/KEY for every page open that you wish to secure - and also...
7 Jan 2022 by Ebuoe
I just hosted my flask app for the first time online, everything seems to be working fine so far except for the sessions, which are not persistent. I have tested the app severally on my local server using the inbuilt flask and gunicorn server ....
19 Mar 2024 by mtoha
Yes, you can use Newtonsoft.JsonSerializer. Json.NET - Newtonsoft[^] Bind your data to one object instance (i.e LoginDataModel), and Serialize string json representation on LoginDataModel dataSession = new LoginDataModel();...