session-variables

How set Session variables in ASP.NET MVC 3 with jQuery?

梦想的初衷 提交于 2019-12-09 05:54:53
问题 So this is the question: how set Session variables in ASP.NET MVC 3 with jQuery? I'm trying to use $.ajax or $.post but the problem is that I don't really know what to do. 回答1: Description Just post to a controller and set the Session variable there. Sample jQuery $(function () { $.post('/SetSession/SetVariable', { key : "TestKey", value : 'Test' }, function (data) { alert("Success " + data.success); }); }); Mvc Controller public class SetSessionController : Controller { public ActionResult

How do I save data on LocalStorage in Ruby on Rails 3.2.8?

萝らか妹 提交于 2019-12-08 23:54:47
问题 I'm trying to save a variable called persistent_data . I usually use session[:persistent_data] or cookies[:persistent_data] , but I would like to use the localstorage instead. How do I do that on Rails? 回答1: Localstorage has nothing to do with rails. You do it the same way as with any other language: <script> localStorage.setItem("company_id", "1"); </script> localStorage.getItem("company_id"); => 1 You can use rails to dynamically set the item however: <script> localStorage.setItem("company

Is a variable stored in Session deserialized once or multiple times throughout a page lifecycle?

∥☆過路亽.° 提交于 2019-12-08 21:23:33
问题 I would like to wrap Session variables in a manner similar to that discussed on CodeProject. public static class WebSession { private const string CurrentUserKey = "CurrentUser"; private static HttpSessionState Session { get { return HttpContext.Current.Session; } } public static bool Exists { get { return Session != null; } } public static User CurrentUser { get { return Session[CurrentUserKey] as User; } set { Session[CurrentUserKey] = value; } } } Here is my question: if I have to access

Passing session variable from page to page

一笑奈何 提交于 2019-12-08 19:47:38
问题 I'm wondering what is my issue on passing a variable from page to page using asp.net session. I've stripped the code down to just one text box to see whats going on. I'm just trying to take the value of a text box and display it on a confirmation page. When the button is clicked it transfers me to the second page but there label is blank. Yes my post back url is pointing to the second page. Here is the button click: protected void submit_Click(object sender, EventArgs e) { string name =

How to store session in when click button start to again click button end time for calculate start to end time in php

无人久伴 提交于 2019-12-08 12:07:30
问题 I want to chart for daily spending hours in browser. In the chart each day spending hours are mentioned. When I click the button time will start and again click the button time will end and finally calculate start to end time stored in like session or any other. This will happen for three days and finally chart will generate. HTML CODE: <html> <body> <form action="time_calculation.php" method="POST"> <input type="submit" name="start" value="Start"> <br><br> <input type="submit" name="end"

How to create an online shopping cart in php

别来无恙 提交于 2019-12-08 10:05:17
问题 I am creating a shopping cart which has four buttons continue shopping, clear cart, update cart and place order I am facing a problem with the sessions like when I press the clear cart button it shows the undefined index cart but the cart comes from the session and when i press the clear cart button it unsets the session of cart so where i am doing it wrong ? can anyone help ? here is my code <?php include("includes/db.php"); include("includes/functions.php"); if($_REQUEST['command']=='delete

javascript - code to clear the cache on closing the browser

陌路散爱 提交于 2019-12-08 07:57:00
问题 In my web application I wants the java script to clear the cache when the user close the browser. The javascript should listen to the event and clear the cache. Can anyone please provide me sample code or any useful link? 回答1: Technically is impossible. What you can do instead is to tell the browser to not cache the page by using the following meta tags: <meta http-equiv='cache-control' content='no-cache'> <meta http-equiv='expires' content='0'> <meta http-equiv='pragma' content='no-cache'>

How can I set a session variable in a servlet and get it in a JSP?

我的梦境 提交于 2019-12-08 06:33:01
问题 I'm learning java and try to pass some variable from servlet to jsp page. Here is code from servlet page @WebServlet("/Welcome") public class WelcomeServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); session.setAttribute("MyAttribute", "test value"); // response.sendRedirect("index.jsp"); RequestDispatcher

Session variable not updating when using Azure cache

倖福魔咒の 提交于 2019-12-08 04:46:20
问题 I have coded an MVC 3 app hosted in Azure. I am using Session variables to store update status information between http calls on one of my long running processes. This is then used to update a progress bar. The values can change pretty rapidly. This all works great when using an InProc session provider. However whenever I change to use the Azure Cache session provider the session variable does not get updated from the long running process. I am now changing things to use Cache variables

ColdFusion: session variables not sticking in website migrated from CF 8 to CF 10

心不动则不痛 提交于 2019-12-08 03:27:44
问题 I manage a ColdFusion-based website that recently migrated from CF 8 to CF 10. The site requires users to log in and keeps certain values in session variables, which are used throughout the site for verification, etc. Since the migration to CF 10, I have been having a lot of trouble with sessions not "sticking" from page to page, particularly after the login process. I had not been using cookies to keep track of values on the client side prior to the migration, nor do I use addtoken="yes" for