Questions tagged [session-variables]

Session variable is a unit of information within a session state. It is maintained across a user's visit within the constraints of the stateless HTTP protocol.

3734 questions
1188
votes
8 answers

How do servlets work? Instantiation, sessions, shared variables and multithreading

Suppose, I have a webserver which holds numerous servlets. For information passing among those servlets I am setting session and instance variables. Now, if 2 or more users send request to this server then what happens to the session variables? Will…
Ku Jon
  • 11,883
  • 3
  • 13
  • 4
478
votes
26 answers

Check if PHP session has already started

I have a PHP file that is sometimes called from a page that has started a session and sometimes from a page that doesn't have session started. Therefore when I have session_start() on this script I sometimes get the error message for "session…
Logan
  • 9,611
  • 12
  • 38
  • 50
170
votes
10 answers

Session variables in ASP.NET MVC

I am writing a web application that will allow a user to browse to multiple web pages within the website making certain requests. All information that the user inputs will be stored in an object that I created. The problem is that I need this object…
Draco
  • 15,378
  • 23
  • 75
  • 90
168
votes
16 answers

Local storage in Angular 2

I need to store data in the browser's session and retrieve the data until the session exits. How do you use local and session storage in Angular 2?
Jaya Kumar B A
  • 1,689
  • 2
  • 7
  • 3
163
votes
7 answers

How to access session variables from any class in ASP.NET?

I have created a class file in the App_Code folder in my application. I have a session variable Session["loginId"] I want to access this session variables in my class, but when I am writing the following line then it gives…
Prashant
  • 25,398
  • 62
  • 159
  • 219
139
votes
5 answers

How to empty/destroy a session in rails?

I can't seem to find it anywhere... How do I delete/destroy/reset/empty/clear a user's session in Rails? Not just one value but the whole thing..
tybro0103
  • 43,805
  • 32
  • 138
  • 167
119
votes
5 answers

How to use sessions in an ASP.NET MVC 4 application?

I am new to ASP.NET MVC. I have used PHP before and it was easy to create a session and select user records based on the current session variables. I have looked everywhere on the Internet for a simple step-by-step tutorial that can show me how to…
65
votes
3 answers

MySQL wait_timeout Variable - GLOBAL vs SESSION

SHOW VARIABLES LIKE "%wait%" Result: 28800 SET @@GLOBAL.wait_timeout=300 SHOW GLOBAL VARIABLES LIKE "%wait%" Result: 300 SHOW SESSION VARIABLES LIKE "%wait%" Result:28800 I am confused by the results. Why does the last query give Result:28800…
Arunjith
  • 855
  • 3
  • 8
  • 12
63
votes
4 answers

How can I get the value of a session variable inside a static method?

I am using ASP.NET page methods with jQuery.... How do I get the value of a session variable inside a static method in C#? protected void Page_Load(object sender, EventArgs e) { Session["UserName"] = "Pandiya"; } [WebMethod] public static…
ACP
  • 32,884
  • 96
  • 217
  • 360
60
votes
7 answers

How to configure a session timeout for Grails application?

In one of controllers in my Grails application I'm preserving a parameter value in a session variable like this: session.myVariable = params.myValue After that, I can access the saved value from different controllers/GSP-pages as long as I actively…
curd0
  • 1,982
  • 3
  • 22
  • 27
60
votes
12 answers

When should I use session variables instead of cookies?

Session variables and cookies seem very similar to me. I understand the technical differences, but how do you decide when to use one vs. the other?
sprugman
  • 17,781
  • 31
  • 105
  • 160
56
votes
5 answers

ASP.NET removing an item from Session?

Which method is preferred? Session.Remove("foo"); Session["foo"] = null; Is there a difference?
David Basarab
  • 67,994
  • 42
  • 125
  • 155
54
votes
4 answers

Are there limits for session variables?

As the title says, are there limits (if any) for session variables or they're considered as usual variables and can store equal amount of data? I'm looking if there are any other limits aside from variable type ones like max length, max values and…
tomsseisums
  • 12,335
  • 19
  • 75
  • 138
54
votes
3 answers

Is there a best practice and recommended alternative to Session variables in MVC

Okay, so first off before anyone attempts to make a determination that this is a "duplicate" question; I have reviewed most of the posts on SO regarding similar questions but even in combination of all that has been said I still am somewhat at a…
Mark
  • 1,587
  • 1
  • 20
  • 44
48
votes
11 answers

HttpContext.Current.Session is null when routing requests

Without routing, HttpContext.Current.Session is there so I know that the StateServer is working. When I route my requests, HttpContext.Current.Session is null in the routed page. I am using .NET 3.5 sp1 on IIS 7.0, without the MVC previews. It…
Loki
  • 1,141
  • 1
  • 9
  • 11
1
2 3
99 100