session-variables

When should I use session variables instead of cookies?

拟墨画扇 提交于 2019-11-28 03:15:11
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? Daniel Vassallo Sessions are stored on the server, which means clients do not have access to the information you store about them. Session data, being stored on your server, does not need to be transmitted in full with each page; clients just need to send an ID and the data is loaded from the server. On the other hand, cookies are stored on the client. They can be made durable for a long time and would allow you to work more smoothly when you have

Spring 3.0 set and get session attribute

本小妞迷上赌 提交于 2019-11-28 03:12:57
I want to read a domain object (UserVO) from session scope. I am setting the UserVO in a controller called WelcomeController @Controller @RequestMapping("/welcome.htm") public class WelcomeController { @RequestMapping(method = RequestMethod.POST) public String processSubmit(BindingResult result, SessionStatus status,HttpSession session){ User user = loginService.loginUser(loginCredentials); session.setAttribute("user", user); return "loginSuccess"; } } I am able to use the object in jsp pages <h1>${user.userDetails.firstName}</h1> But I am not able to read the value from another Controller, I

Set Session variable using javascript

喜夏-厌秋 提交于 2019-11-28 01:22:03
<script type="text/javascript"> function checkQuery() { var val = form1.proDown.options[form1.proDown.options.selectedIndex].value; var txt = form1.proDown.options[form1.proDown.options.selectedIndex].text; //alert(val+' | '+txt); <?php $_SESSION['value1']= ?> = txt; <?php ; ?> } </script> I have this code and it does not Work? Any One have solution for accessing javascript variable into $_SESSION[]. I think you should use xhr(Ajax) to store your data into php session. Following is a simple example to do this jQuery.ajax({ url: 'storesession.php', type: 'POST', data: { txt: txt, }, dataType :

mvc 5 session timeout after default period (20 mins)

旧巷老猫 提交于 2019-11-27 20:30:43
My MVC 5 site has web.config like this: <authentication mode="Forms"> <forms name=".ADAuthCookie" loginUrl="~/Account/Login" timeout="2880" slidingExpiration="true" protection="All" /> </authentication> but timeout doesn't work. It doesn't matter what value I give here, it always expires after 20-30 mins. How can I maintain users logged in for longer period or until they sign-out? Is there any way I can achieve this using "In-Proc" only? Or I am missing something here? Kelly Gendron You are dealing with two separate issues, auth timeout and session timeout. Session timeout is controlled by the

How to configure a session timeout for Grails application?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 17:41:12
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 use the app. However, if I don't use my app for a while, even though my browser window is still open, the session variable looses it's value. Does this happens because the session expires? I was under impression that a session lives until the browser window is still open, but apparently I was wrong. What should I do to ensure all session variables I

How to empty/destroy a session in rails?

我的梦境 提交于 2019-11-27 17:33:27
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.. To clear the whole thing use the reset_session method in a controller. reset_session Here's the documentation on this method: http://api.rubyonrails.org/classes/ActionController/Base.html#M000668 Resets the session by clearing out all the objects stored within and initializing a new session object. Good luck! Lavixu session in rails is a hash object. Hence any function available for clearing hash will work with sessions. session.clear or if specific

PHP session variables not being maintaned

谁说我不能喝 提交于 2019-11-27 15:50:53
I have an application that has been working with session variables no problem. I start the session before the headers on every page that uses when, it has been fine then it seems all of a sudden I'm getting an undefined index error when I navigate to a page other than the one that sets up the session variables. But only on some browsers . Sometimes sessions are maintained and sometimes they aren't. It seems that cookies aren't being stored some of the time. I've done checks using different browsers and sometimes cookies are stored and sometimes not. I did an experiment. I was using firefox to

Storing database connection in a session variable [duplicate]

佐手、 提交于 2019-11-27 15:41:21
Possible Duplicate: Can't pass mysqli connection in session in php Many of us have written PHP applications that require databases; mostly MySQL, but I have often used very small MS Access databases for people less technically capable so they can download an tweak them/save backups/etc. on their own (whether this is correct or not, I have no idea). What I notice, is a lot of time is spent connecting and running some of the same queries. Because of this I had an interesting thought: Storing the connection and possible result sets that are mostly static in a $_SESSION variable to reduce the

Controller SessionStateBehavior is ReadOnly and I can update Session Variable

纵饮孤独 提交于 2019-11-27 15:35:48
问题 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)] public class GLobalController : Controller { public ActionResult Index() { Session["xxx"] = DateTime.Now.ToString(); return View(); } 回答1: see Writing to a read only session in MVC 3+ That post claims the behavior is inconsistent. I am definitely able

Session variable value is getting null in ASP.NET Core

不羁岁月 提交于 2019-11-27 13:09:25
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 Index() { HttpContext.Session.SetString("Test", "Hello!"); var message = HttpContext.Session.GetString("Test");// Here value is getting correctly return View(); } public IActionResult About() { var message = HttpContext.Session.GetString("Test"); // This value is always getting null here return View(); } } Here is my session configuration in Startup class: