session-variables

Is it possible to set localStorage or Session variable in asp.net page and read it in javascript on the other page?

独自空忆成欢 提交于 2019-12-04 03:31:48
问题 As in question. Is it possible to set variable in asp.net page in localStorage and retrieve it on the other page? How to set localStorage variable in asp.net. Is it possible? After that I could read variable using: localStorage.getItem('UserID'); 回答1: I guess You can't. The whole point of local storage is that it is local and You can manipulate it only from javascript. If You need to pass values between server and client You need to use some transport technology - cookies, ajax calls, hidden

Multiple sessions in one instance using PHP?

前提是你 提交于 2019-12-04 01:52:44
问题 I have a project where I would like to create two session cookies in one browser. The first session would be to uniquely identify a person, the second would be to share events within the session between users. I have been using a database for this, but would like the data to disappear when the session dies. There are no logins within the system. Is there a way to do this, other than creating a cookie system to replicate functionality? For example, we would have two session cookies: name

ASP.NET MVC Unit Testing - Sessions

坚强是说给别人听的谎言 提交于 2019-12-03 15:13:54
问题 Having searched StackOverflow, and Google I think what I'm doing is suppose to be right, however results don't seem to be going well [TestMethod] public void LoginAction_Should_Return_View_and_User_Authenticated() { // Arrange var mock = new Mock<ControllerContext>(); var mockSession = new Mock<HttpSessionStateBase>(); mock.Setup(p => p.HttpContext.Session).Returns(mockSession.Object); var testData = FakeUserData.CreateTestUsers(); var repository = new FakeUserRepository(testData); var

Maintaining Session Variables across Subdomains

走远了吗. 提交于 2019-12-03 14:46:28
问题 I have been trying to maintain session vars between two subdomains and found it impossible. I ended up creating 2 minimal PHP web pages as a test bed, one I call 'test 1' just sets $_SESSION['test'] = "Fred"; and has a hyperlink to 'test 2' which simply tries to echo the value of $_SESSION['test'] to prove it's worked, or not. I place 'test 1' in my www domain and 'test 2' in my sub domain. I try various version of what should go in the header, from various sources. Here are the main 3 (and

strongly typed sessions in asp.net

巧了我就是萌 提交于 2019-12-03 14:29:09
Pardon me if this question has already been asked. HttpContext.Current.Session["key"] returns an object and we would have to cast it to that particular Type before we could use it. I was looking at various implementations of typed sessions http://www.codeproject.com/KB/aspnet/typedsessionstate.aspx http://weblogs.asp.net/cstewart/archive/2008/01/09/strongly-typed-session-in-asp-net.aspx http://geekswithblogs.net/dlussier/archive/2007/12/24/117961.aspx and I felt that we needed to add some more code (correct me if I was wrong) to the SessionManager if we wanted to add a new Type of object into

is it a good idea to create an enum for the key names of session values?

泪湿孤枕 提交于 2019-12-03 13:15:21
instead of doing session("myvar1") = something session("myvar2") = something session("myvar3") = something session("myvar4") = something is doing enum sessionVar myvar1 myvar2 myvar3 myvar4 end enum session(sessionVar.myvar1.tostring) = something session(sessionVar.myvar2.tostring) = something session(sessionVar.myvar3.tostring) = something session(sessionVar.myvar4.tostring) = something would be better? Instead of using constants for the session keys, I'm using my own type-safe session object, which looks like this (sorry this is in C#, see below for a VB version): public class MySession { //

How to get ELMAH to include session values?

久未见 提交于 2019-12-03 12:19:41
NOTE: I know the various reasons to avoid using the session, but this is a project I've inherited, so please skip that part of any replies :) Since it's a solved problem, I'm hoping someone can point to an ELMAH patch/branch/fork that includes logging session data rather than reinventing the wheel. One weird thing is an older post from Atif that says they're already logged: http://markmail.org/message/ncmdgwm5rmzewbwu commenter henningst mentioned adding in the session variables here: http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx Another approach (I'd

Sharing Session State between different .NET Versions using State Server

孤街醉人 提交于 2019-12-03 10:32:29
Background We have one website running on IIS 6 (Win2003 Server) using .NET 3.5: site1.mysite.local We have a second website running on IIS 7 (Win2008 Server) using .NET 4.0: site2.mysite.local On each site, the web.config contains the StateServer and the same machineKey: <sessionState mode="StateServer" stateConnectionString="tcpip=STATESRV01:42424" /> <machineKey decryptionKey="EDCDA6DF458176504BBCC720B4E29348E252E652591179E2" validationKey="CC482ED6B5D3569819B3C8F07AC3FA855B2FED7F0130F55D8405597C796457A2F5162D35C69B61F257DB5EFE6BC4F6CEBDD23A4112C4519F55185CB5EB3DFE61"/> We also have a

Understand “current_user” concept when creating a login session in ruby

瘦欲@ 提交于 2019-12-03 08:38:53
I am going through the great Michael Hartl tutorial to build ruby app here . I am trying to understand the concept of how to create a session and I am stuck in understanding this line: self.current_user = user in this method: module SessionsHelper def sign_in(user) cookies.permanent[:remember_token] = user.remember_token self.current_user = user end end I understand the whole concept of creating a cookie with the user_token. But I don't understand what does self.current_user = user means and why is it even necessary to keep this line of code - I have the cookie with the token - why do I need

Spring MVC - difference between HttpSession.setAttribute and model.addObject

☆樱花仙子☆ 提交于 2019-12-03 07:33:56
I am trying to learn Spring MVC recently. It seems that i did not understand well the functionalities of @ModelAttribute annotation and HttpSession. @SessionAttributes({"shoppingCart", "count"}) public class ItemController { @ModelAttribute("shoppingCart") public List<Item> createShoppingCart() { return new ArrayList<Item>(); } @ModelAttribute("count") public Integer createCount() { return 0; } @RequestMapping(value="/addToCart/{itemId}", method=RequestMethod.GET) public ModelAndView addToCart(@PathVariable("itemId") Item item, @ModelAttribute("shoppingCart") List<Item> shoppingCart,