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.
Questions tagged [session-variables]
3857 questions
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,159
- 1
- 9
- 11
48
votes
3 answers
What is the right time for ViewData, ViewBag, Session, TempData
I was editing a project and I saw a Session[""] in one controller method and TempData[""] in another. Is there a difference between the 4 or is it just 4 ways to do the same thing.

MrM
- 21,709
- 30
- 113
- 139
46
votes
6 answers
Magento - Passing data between a controller and a block
Really quick and simple question but I can't find a decent answer to this - What is the best way to pass data from a controller to a block in Magento.
Incase it makes a difference, I am loading the layout as follows:
…

Drew Hunter
- 10,136
- 2
- 40
- 49
45
votes
5 answers
Session variable value is getting null in ASP.NET Core
I am setting a session variable in one method and trying to get the session variable value from the another method in a controller but its always getting null:
Here is my code:
public class HomeController : Controller
{
public IActionResult…

TanvirArjel
- 30,049
- 14
- 78
- 114
43
votes
5 answers
PHP session side-effect warning with global variables as a source of data
I'm trying to host a PHP web site that was given to me. I see this warning:
Warning: Unknown: Your script possibly
relies on a session side-effect which
existed until PHP 4.2.3. Please be
advised that the session extension
does not…

Zack Peterson
- 56,055
- 78
- 209
- 280
37
votes
4 answers
Session Variables: How much data is too much?
I've only seen examples of session variables being used to store small amounts of data, like a single user id. I'm wondering if it would be more efficient to instead hold more frequently accessed data in the session variables to avoid querying the…

user1537360
- 4,751
- 6
- 26
- 22
36
votes
3 answers
Where are the session variables saved?
Where exactly are session variables saved? Cookies? Server memory?
Again where are Application variables saved?

Manish
- 6,106
- 19
- 64
- 90
35
votes
8 answers
Setting a PHP $_SESSION['var'] using jQuery
I need to set a PHP $_SESSION variable using the jQuery. IF the user clicks on an image I want to save a piece of information associated with that image as a session variable in php.
I think I can do this by calling a php page or function and…

mmundiff
- 3,875
- 7
- 32
- 46
35
votes
6 answers
Shopping cart persistence: $_SESSION or browser cookie?
On an e-commerce site with no username/login to persist cart data, would it be better to use the PHP $_SESSION variable or a browser cookie to persist items in the shopping cart? I am leaning toward $_SESSION since cookies can be disabled, but would…
user1193509
35
votes
3 answers
Controller SessionStateBehavior is ReadOnly and I can update Session Variable
I expect that if controller has attribute SessionStateBehavior.ReadOnly then I can't change session variables inside this controller
but I can change values.
I try this code
[SessionState(System.Web.SessionState.SessionStateBehavior.ReadOnly)]
…

user1223234
- 353
- 1
- 3
- 5
32
votes
7 answers
View php session variables
Not sure if this belongs here or at webapps... please move if appropriate.
I don't even know if such a thing is possible, but is there an extension or add-on for either Firefox or Chrome that would let me view all my PHP session variables the way…

EmmyS
- 11,892
- 48
- 101
- 156
32
votes
4 answers
Setting session variable using javascript
I am getting name and email id of a user after he logs in via facebook to my website..
I want to add those variables in session on login form itself using javascript;
I tried following:
FB.api('/me', function(me) {
if (me.name) {
…

Sam
- 471
- 2
- 5
- 9
32
votes
4 answers
Static fields vs Session variables
So far I've been using Session to pass some variables from one page to another. For instance user role. When a user logs in to the web application the role id of the user is kept in Session and that role is checked at different parts of the…

Mikayil Abdullayev
- 12,117
- 26
- 122
- 206
30
votes
2 answers
What are the benefits of a stateless web application?
It seems some web architects aim to have a stateless web application. Does that mean basically not storing user sessions? Or is there more to it?
If it is just the user session storing, what is the benefit of not doing that?

Genadinik
- 18,153
- 63
- 185
- 284
29
votes
1 answer
Webmethods with HttpContext.Current.User.Identity.IsAuthenticated stop working after inactivity on Azure
I'm testing the Azure server with pages that use Ajax(json)/Webmethod functions.
Some of those functions check HttpContext.Current.User.Identity.IsAuthenticated before they run code. Unfortunately, if a user is logged in and the page doesn't make a…

Gloria
- 1,305
- 5
- 22
- 57