session-variables

How to insert javascript value into the php session variable

女生的网名这么多〃 提交于 2019-11-28 14:15:08
I want to insert javascript value into the php session variable but inside the javascript function. Here is what I have tried and it is not working: function languageChange() { var lang = $('#websites1 option:selected').val(); <?php $_SESSION['SESS_LANGUAGE']?> = lang; alert(<?php echo $_SESSION['SESS_LANGUAGE']?>); } You cannot access it directly (the way you are doing). However, it can be done using AJAX. Here is the perfectly working solution. Here is the HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html

php session variable lost

你说的曾经没有我的故事 提交于 2019-11-28 14:12:37
I work with php5 and apache2 on my development machine. The production server is apparently similar. I have a script set_language.php that creates a session variable according to the language chosen: <?php session_start(); $back = $_SERVER['HTTP_REFERER']; if (isset($_GET['lang'])) { if ($_GET['lang'] == 'fr') $_SESSION['lang'] = 'fr'; else if ($_GET['lang'] == 'en') $_SESSION['lang'] = 'en'; } header( "Location: $back" ) ; exit(); ?> Then I include the code below on all pages: session_start(); if(isset($_SESSION['lang']) && $_SESSION['lang'] == 'en') { require('lang_en.php'); } else if(isset(

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

三世轮回 提交于 2019-11-28 12:31:22
问题 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

Session object changes when object is updated in C#

大兔子大兔子 提交于 2019-11-28 12:21:04
I have this really weird problem and I'm sure I'm missing something obvious here. I have these two lines: HttpContext.Current.Session[listModelType + "ListModel"] = listModel; listModel.ProductRows = new Collection<ProductRow>(listModel.ProductRows.Where(r => r.ParentRowId == 0).ToList()); After the second line is executed my session object is updated as well (according to "Watch" in Visual Studio) What am I missing here? I have tried int i = 0; HttpContext.Current.Session["i"] = i; i++; and HttpContext.Current.Session["i"] remains 0. See value types and reference types . The int is a value

Cross framework authentication zend + codeigniter

扶醉桌前 提交于 2019-11-28 12:02:07
问题 Zend_Auth uses PHP Session but, codeigniter has a different approach altogether. The project that I am working on requires that anyone who hasIdentity() in zend, when logs into another system which uses codeigniter, should not have issues to browse around. How do I set Codeigniter session when I authenticate the user on zend system and next step is - vice-versa. Thanks in Advance. EDIT: Both the sites are using different database but, users are indexed together. 回答1: A quick workaround is to

jsp:useBean scope

自古美人都是妖i 提交于 2019-11-28 11:44:45
The JSP code is : <jsp:useBean id="person" class="org.example.model.PersonModel" scope="session"> </jsp:useBean> <br> Name : <jsp:getProperty property="name" name="person"/> <br> Surname : <jsp:getProperty property="surname" name="person"/> Although I set java object in the request scope and not in the session scope in the Controller Servlet from where I am forwarding the request to this Servlet . How does the <jsp:useBean> gets hold of the request attribute although scope mentioned in the tag is session? If it uses pageContext.findAttribute() to get the attribute, then what is the use of

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

*爱你&永不变心* 提交于 2019-11-28 11:10:02
问题 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? 回答1: 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

PHP $-SESSION variables disappear on new page and return empty

会有一股神秘感。 提交于 2019-11-28 11:00:19
问题 I'm having an issue with the Sessions Variables. Ever since i switched from mysqli to PDO. It worked fine with mysqli, but ever since i switched to PDO, this issue has now come forward. I'm trying to login and i have an area, where i want to make sure that the user can only see, if the user is logged in. The login works fine, but as soon as i get referred to my index file, i don't see anything, because of the logged in function. I can see the $_SESSION Variable gets filled, but as soon as i

Why HttpContext.Current.Session is null in Global.asax?

安稳与你 提交于 2019-11-28 09:50:25
I'm using VS2010 and created a simple asp. web forms application, using Development Server to test it. I try to store user data - queried from sql server - in the session, since I don't want to access database in every request. I'm using the 'Application_AuthenticateRequest' and the 'Session_Start' methods. First round: AuthenticateRequest called. The following code ran: public static void Initialize(string login_name, bool force_refresh) { HttpSessionState Session = HttpContext.Current.Session; object o = Session == null ? null : Session["EMPLOYEE_DATA"]; if (force_refresh || o == null || o

can a php $_SESSION variable have numeric id thus : $_SESSION['1234’]

天涯浪子 提交于 2019-11-28 08:56:09
问题 I've been driving myself nuts with this problem. I'm creating a session id dynamically in order to retain the page state on refresh. If a page element is clicked, I take the id of the element and pass it to my server side script which creates the session variable: $_SESSION[$id] = $id; Bizarrely, this was working only some of the time, I narrowed it down to the fact that some elements have a purely numeric id and others do not: if (is_numeric($id)) { $_SESSION[$id] = $id; $_SESSION['test'] =