session-variables

When should I use session variables instead of cookies?

落爺英雄遲暮 提交于 2019-12-17 17:28:45
问题 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? 回答1: 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

Storing database connection in a session variable [duplicate]

南笙酒味 提交于 2019-12-17 14:02:52
问题 This question already has answers here : Closed 7 years ago . 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

How to empty/destroy a session in rails?

痞子三分冷 提交于 2019-12-17 10:17:47
问题 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.. 回答1: 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! 回答2: session in rails is a hash

Session variable value is getting null in ASP.NET Core

空扰寡人 提交于 2019-12-17 09:30:20
问题 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

Session variable value is getting null in ASP.NET Core

孤人 提交于 2019-12-17 09:30:15
问题 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

How can I get the value of a session variable inside a static method?

匆匆过客 提交于 2019-12-17 07:17:08
问题 I am using ASP.NET page methods with jQuery.... How do I get the value of a session variable inside a static method in C#? protected void Page_Load(object sender, EventArgs e) { Session["UserName"] = "Pandiya"; } [WebMethod] public static string GetName() { string s = Session["UserName"].ToString(); return s; } When I compile this I get the error: An object reference is required for the non-static field, method, or property 'System.Web.UI.Page.Session.get'` 回答1: HttpContext.Current.Session[".

Sharing SESSION Variables Between Multiple Subdomains

与世无争的帅哥 提交于 2019-12-17 06:12:36
问题 I have a website www.example.com. That will have multiple subdomains that work with a single application or program. For an example, login.example.com will allow the user to log in to the site while system.example.com will allow the user to access an information system, while forums.example.com will allow the user to access forums. We may need to pass information between the subdomains such as a user id, or a user preference, etc. How do we go about passing information between the sudomains

Sharing SESSION Variables Between Multiple Subdomains

那年仲夏 提交于 2019-12-17 06:12:16
问题 I have a website www.example.com. That will have multiple subdomains that work with a single application or program. For an example, login.example.com will allow the user to log in to the site while system.example.com will allow the user to access an information system, while forums.example.com will allow the user to access forums. We may need to pass information between the subdomains such as a user id, or a user preference, etc. How do we go about passing information between the sudomains

Are there limits for session variables?

亡梦爱人 提交于 2019-12-17 04:56:07
问题 As the title says, are there limits (if any) for session variables or they're considered as usual variables and can store equal amount of data? I'm looking if there are any other limits aside from variable type ones like max length, max values and so on. P.S. If the question is unclear, please let me know. Thanks in advance! 回答1: As @Thariama said, there's no limit on the number of variables; also, there's no limit on the amount of data you can store in a session (I've seen sessions tens of

Session variables not working php

霸气de小男生 提交于 2019-12-16 19:44:23
问题 Here are the code of my login page where the login script checks for the authenticity of the user and then redirects to inbox page using header function. <?php session_start(); include_once('config.php'); $user=htmlentities(stripslashes($_POST['username'])); $password=htmlentities(stripslashes($_POST['password'])); // Some query processing on database if(($id_user_fetched<=$id_max_fetched) && ($id_user_fetched!=0)){ $_SESSION['loggedIn'] = 'yes'; header("Location:http://xyz/inbox.php?u=$id