session-variables

Where I should declare a session variable in asp.net

狂风中的少年 提交于 2019-11-29 20:31:16
问题 I am building a Asp.net Application. I need to save a HashTable in a session. At page load i am writing protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Session["AttemptCount"]=new Hashtable(); //Because of this line. } } Here problem is, when a user refresh the page, session["AttemptCount"] also get refreshed. I want to know where should I declare Session["AttemptCount"]=new Hashtable(); So that my seesion do not get refeshed. EDIT In Global.asax, this session

Node.js express-session what does the proxy option do?

若如初见. 提交于 2019-11-29 17:56:58
app.use(session( { ... proxy: true, resave: true, saveUninitialized: true } )); I found a tutorial on express-session and they have an proxy: true option. Can I leave it on true? What does this do? Is it better to include it? I know what a proxy is however I don't really get why this is an option? The fine manual states: Trust the reverse proxy when setting secure cookies (via the "X-Forwarded-Proto" header). This refers to situations where clients don't connect directly to your Node server, but through a reverse proxy. For instance, clients connect to an NGINX webserver, which forwards the

Advanced WordPress Single Post Pagination - Exclude Category & Browse Through Only Set Categories

耗尽温柔 提交于 2019-11-29 17:34:17
I have my main blog, which lists all posts. I also have a category page that lists only posts from 1 category. Main Blog Post #1 Post #2 Post #3 Post #4 Post #5 Category A Page Post #1 Post #3 Post #4 Category B Page Post #1 Post #3 Post #5 If a user clicks to look at a post, and then uses the default next/prev link functions, there is no way for WordPress to know which post should be next. For example, if the user is looking at Post #3, should the next post be #4 or #5? It all depends on where the user came from. So I wrote the following code to answer this problem and thought I'd share it.

What can be the maximum size for the $_SESSION?

偶尔善良 提交于 2019-11-29 14:53:47
I am importing a csv file with more then 5,000 records in it. What i am currently doing is, getting all file content as an array and saving them to the database one by one. But in case of script failure, the whole process will run again and if i start checking the them again one by one form database it will use lots of queries, so i thought to keep the imported values in session temporarily. Is it good practice to keep that much of records in the session. Or is there any other way to do this ? Thank you. If you have to do this task in stages (and there's a couple of suggestions here to improve

codeigniter sess_destroy() not working properly,what m i doing wrong?

倾然丶 夕夏残阳落幕 提交于 2019-11-29 13:36:40
I am a newbie in codeigniter. I am using an an login form to login as an admin. When the admin logs in with the correct user name and password s/he is directed to the home page with a session variable.and then if he clicks the log out button the session is supposed to be destroyed and redirect the user to log in page i.e log in form page. The 1st controller is admin: <?php class Admin extends CI_Controller { function index() { $data['main_content'] = 'admin/log_in'; $this -> load -> view('includes/admin/admin_template', $data); } function log_in() { $this->load->model('admin_model'); $query =

Why is my SESSION array OK on one page but empty on another?

核能气质少年 提交于 2019-11-29 13:09:36
I have a class that sets various session variables. After I set the session variable I do a var dump of SESSION and get an output of them all. all good so far. Then I navigate to another page. session_start(); // i call this right after opening the php tag var_dump($_SESSION); // i call this after setting the variables and it's empty this time? Setting my sessions while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)) { $_SESSION['atid'] = $row['autotaskid']; $_SESSION['bmsid'] = $row['bmsid']; $_SESSION['shavlikid'] = $row['shavlikid']; $_SESSION['cpid'] = $row['cpid']; } Trying to use

Making $_SESSION available in controllers

旧巷老猫 提交于 2019-11-29 12:43:18
I'm trying to make the $_SESSION global available within the controllers of my framework written from scratch. It's not quite MVC, the presentation layer consists of two parent classes with multiple child classes. Without going into great detail, my views are rendered in class Template class Template{ protected $_controller; protected $_action; function __construct($controller,$action) { $this->_controller = $controller; $this->_action = $action; } function render(){ if (file_exists(APP_ROOT . DS . 'app' . DS . 'view' . DS . $this->_controller . DS . $this->_action . '.php')) { include (APP

mocking session variable in unit test using Moles

痴心易碎 提交于 2019-11-29 11:56:09
Method I am unit testing checks for a session variable like if(Session["somevar"] != null) { // rest of the code } In my test, not able to get rid of this since Session is null, it's throwing null referrence exception. To bypass this, I have tried mocking it like below but no luck System.Web.Moles.MHttpContext.AllInstances.SessionGet = (HttpContext cntx) => { return (HttpSessionState)cntx.Session["somevar"]; } I even tried method mention here to simulate HttpContext and then doing below HttpContext.Current = new HttpContext(workerRequest); HttpContext.Current.Session["somevar"] = value; But

HTTPSession variable limit

こ雲淡風輕ζ 提交于 2019-11-29 10:57:21
What is the maximum limit (i.e. size) of data that a HTTPSession variable can hold? What will happen if this exceeds? And most importantly, what is the alternative approach to have the data throughout the session if the size exceeds the maximum size that a HTTPSession variable can hold? There is no limit, other than the memory of your server. The alternatives are to run your server with more memory to configure the server to swap sessions to disk (see http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html for Tomcat) to avoid putting large data in the session, and to use a cache or a

Sharing SQL Server Session State across Web Applications

巧了我就是萌 提交于 2019-11-29 08:40:15
问题 I'm setting up a very basic demo of SQL Server Session State, but am having some trouble getting it working. I'm trying to test this out locally running Windows 7 with IIS 7.5 and SQL Server 2008 R2. Ultimately, I need a way to track the number of users logged into a system that is load-balanced between a few different web servers. So I need to update a session variable (stored in SQL) every time a user logs in or out. So the session ID could always be different. Is this possible? Here's what