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
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,119
  • 2
  • 37
  • 48
44
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
  • 20,601
  • 29
  • 103
  • 136
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
  • 53,106
  • 76
  • 203
  • 279
41
votes
3 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
  • 22,594
  • 10
  • 59
  • 91
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
  • 5,648
  • 18
  • 56
  • 89
36
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,385
  • 6
  • 23
  • 22
34
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,655
  • 7
  • 29
  • 42
34
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
32
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
  • 323
  • 1
  • 3
  • 5
31
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,164
  • 41
  • 98
  • 147
31
votes
10 answers

Set session variable in laravel

I would like to set a variable in the session using laravel this way Session::set('variableName')=$value; but the problem is that I don't know where to put this code, 'cause I would like to set it for one time (when the guest visite the home page…
31
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
  • 11,458
  • 22
  • 103
  • 189
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
  • 16,715
  • 59
  • 170
  • 277
30
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,335
  • 3
  • 19
  • 49
28
votes
5 answers

Web authentication state - Session vs Cookie?

What's the best way to authenticate and track user authentication state from page to page? Some say session state, some say cookies? Could I just use a session variable that has the ID of the user and upon authentication, instatiate a custom User…
Bill
  • 407
  • 2
  • 5
  • 8