session-variables

Local storage in Angular 2

本小妞迷上赌 提交于 2019-11-26 14:17:50
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? The standard localStorage API should be available, just do e.g.: localStorage.setItem('whatever', 'something'); It's pretty widely supported . Note that you will need to add "dom" to the "lib" array in your tsconfig.json if you don't already have it. To store data in local-storage, localStorage.setItem('key', 'value'); Make sure to stringify value, for example if you have an object localStorage.setItem(itemName, JSON.stringify(itemData)); OR for

Static fields vs Session variables

人盡茶涼 提交于 2019-11-26 13:09:58
问题 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 application. I\'ve recently started thinking why not use static members instead. I can store the same information in a static field and easily access it anywhere in my application (well anywhere the namespace in which that static field resides is included

Setting a PHP $_SESSION['var'] using jQuery

醉酒当歌 提交于 2019-11-26 12:06:48
问题 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 appending that piece of info to the query string. Any ideas. I have found little help through google. thanks mike 回答1: You can't do it through jQuery alone; you'll need a combination of Ajax (which you can do with jQuery) and a PHP back-end. A very

HttpContext.Current.Session is null when routing requests

喜夏-厌秋 提交于 2019-11-26 08:53:34
问题 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 appears that AcquireRequestState is never fired when using the routes and so the session variable isn\'t instantiated/filled. When I try to access the Session variables, I get this error: base {System.Runtime.InteropServices.ExternalException} = {\

What is the right time for ViewData, ViewBag, Session, TempData

时光毁灭记忆、已成空白 提交于 2019-11-26 07:23:18
问题 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. 回答1: ViewData/ViewBag - valid only for the duration of the current request. You set it in a controller action and use it in the view, then it disappears. The difference is that the first is a dictionary whereas the second is just a dynamic wrapper around this dictionary. Both point to the same data though.

Local storage in Angular 2

醉酒当歌 提交于 2019-11-26 04:11:51
问题 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? 回答1: The standard localStorage API should be available, just do e.g.: localStorage.setItem('whatever', 'something'); It's pretty widely supported. Note that you will need to add "dom" to the "lib" array in your tsconfig.json if you don't already have it. 回答2: To store data in local-storage, localStorage.setItem('key', 'value'); Make sure to

Session variables in ASP.NET MVC

久未见 提交于 2019-11-26 01:34:53
问题 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 to be accessed from any part of the website and I don\'t really know the best way to accomplish this. I know that one solution is to use session variables but I don\'t know how to use them in asp .net MVC. And where would I declare a session

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

醉酒当歌 提交于 2019-11-26 00:32:11
问题 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 error Session[\"loginId\"] Can anyone tell me how to access session variables within a class which is created in app_code folder in ASP.NET 2.0 (C#) 回答1: (Updated for completeness) You can access session variables from any page or control using Session["loginId"] and from

How to use store and use session variables across pages?

家住魔仙堡 提交于 2019-11-26 00:13:29
问题 When one page is accessed, I would like to start a session and store a session variable: <?php session_start(); $_SESSION[\'myvar\']=\'myvalue\'; ?> Then from another page, I would like to check if that session variable has been stored: <?php session_start(); echo(\"1\"); if(isset($_SESSION[\'myvar\'])) { echo(\"2\"); if($_SESSION[\'myvar\'] == \'myvalue\') { echo(\"3\"); exit; } } ?> This code does not work for me. 回答1: Reasoning from the comments to this question, it appears a lack of an

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

人走茶凉 提交于 2019-11-25 23:55:26
问题 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 they all be common for all the users or they will be different for each user. If they are different, then how was the server able to differentiate between different users? One more similar question, if there are n users accessing a particular