session-variables

mysql_real_escape_string() for $_SESSION variables necessary?

∥☆過路亽.° 提交于 2019-12-04 08:38:31
Should I use the mysql_real_escape_string() function in my MySQL queries for $_SESSION variables? Theoretically, the $_SESSION variables can't be modified by the end-user unlike $_GET or $_POST variables right? Thanks :) Regardless of whether the user can modify the data, you probably want to escape it anyway in case you ever need the data to contain characters that would break the SQL (quotes, etc). Better yet, use bound parameters and you won't have to worry about it. Do not escape/quote/encode text until you're at the point where you need it. Internal representations should be as "raw" as

ASP.Net Session data lost between pages

混江龙づ霸主 提交于 2019-12-04 07:18:39
I came across a weird behavior today w/ my web application. When I navigate from a page to another, I lose one particular session variable data. I'm able to launch the app in firefox and able to see that the session data is not lost. I use Response.Redirect(page2, false) to redirect to another page. Below code was used to track session variables System.IO.StreamWriter sw = new System.IO.StreamWriter(@"c:\test.txt", true); for (int i = 0; i < Session.Count; i++) { sw.WriteLine(Session.Keys[i] + " " + Session.Contents[i]); } sw.Close(); Can anyone help me in this? Any help is appreciated. I was

Major PHP/MySQL Login Project, with session variables

时光总嘲笑我的痴心妄想 提交于 2019-12-04 06:42:42
问题 Alright, so for the past two days, I've been scouring the internet and trying my best to put together a rather sophisticated login system. I've got the core of it working, users can sign up, and login. I'm not new to simple php and mysql, but when it comes to in-depth code like this I'm lost. Basically what I want is to have the users enter their login, then have it verified (obviously) and I have that done, then be redirected to a members page that displays information pertaining to their

How to assign JavaScript variable to PHP session variable?

◇◆丶佛笑我妖孽 提交于 2019-12-04 06:37:30
问题 Here's javascript code that i have var randomnum = 30; and here's PHP code <?php $_SESSION['numbertoguess'] = '<script>document.write(randomnum)</script>';?> But this is not passing the value But when i am trying this code below, it works. It gives session variable that the value 'a sample thing'. <?php $_SESSION['numbertoguess'] = 'a sample thing';?> 回答1: Look at the following code. The PHP session is assigned to 30 from the Javascript value. however am not sure if this is good way for

PHP Sessions shopping cart: update product if it's already id the session

时间秒杀一切 提交于 2019-12-04 06:04:54
问题 I have struggled to find a solution to a simple shopping cart with $_SESSION . I kept it very simple and this is my code right now if ( Input::isPost('add') ) { $id = Input::get('id'); $qta = Input::post('qta'); $size = Input::post('size'); if ( !isset($_SESSION['cart']) ) { $_SESSION['cart'] = array(); } if ( array_key_exists($id, $_SESSION['cart']) ) { if ( $_SESSION['cart'][$id][0] == $size ) { $_SESSION['cart'][$id][1]+=$qta; } else { $_SESSION['cart'][$id] = array( $size, $qta ); } }

Insert multiple rows from array saved in a session into table?

我只是一个虾纸丫 提交于 2019-12-04 05:55:55
问题 I'm passing multiple state values that are stored in a session variable, into a MySQL table via php using one insert command and I'm wondering if its possible to insert each state value into a different row. I also have an ID saved in a variable that I would like to insert with each state. $campaign_id Each state is stored in this session variable. print_r($_SESSION['stateslist']); Assuming I have two states saved in the $_SESSION['stateslist'] (NY, CA) and campaign ID 5, I would like my

Spring MVC: HTTP session management “equivalent”

孤者浪人 提交于 2019-12-04 05:28:49
问题 I come from languages like PHP or ColdFusion: if I wanted to save something in user's http session I act like this: SESSION["foo"] = "bar" Now I am in a Spring MVC environment. For example, inside a Controller method, how can I save a variable in session? Someone told me that a session-scoped bean would get the job. Can you help me with a trivial code snippet? 回答1: You may use a session-scoped bean, and you may also have an argument of type HttpServletRequest or HttpSession on all your

How to Persist data using session variable in mvc3 razor view?

这一生的挚爱 提交于 2019-12-04 05:09:54
I am working in MVC3 Application with Razor. In my Account controller after validating the user, i am getting the user ClientID from Database. Here i want to persist ClientID in Session variable. which was using across the all controller and Razor view. I have no idea as to what is the best way to implement this.OR How to persist data in the session variable. And how to use persisted data in the session variable in across the controller. Thanks for your help.. If you are using ASP.NET Forms Authentication, the user name is already stored in a cookie. You can access it from the Controller via

Expanding environment variables for command prompt

别说谁变了你拦得住时间么 提交于 2019-12-04 04:04:17
问题 I would like to run a cmd.exe that would evaluate environment variables at call time instead of when it parses the command. If I set the BASE to 2 and echoing it, I should see the number 2, although running this script does not properly set the base. Expected Behavior: C:\Users\schristo>cmd.exe /X /C "set BASE=2 && echo %BASE% && pause" 2 Press any key to continue . . . Actual behavior: C:\Users\schristo>cmd.exe /X /C "set BASE=2 && echo %BASE% && pause" %BASE% Press any key to continue . . .

Codeigniter duplicate session issue

放肆的年华 提交于 2019-12-04 03:46:47
I have an application built with codeigniter using the sessions class and storing session data in a database. The problem is I'm getting extra session records in my database when my webpage loads a css file. Up until recently I was running my application on a simple VPS host provided by rackspace. Database and Apache were both running on the same VPS. Recently however I've migrated my application to PHPFog to allow it to scale more easily. I didn't have this issue with my former hosting setup. The row with the populated value for user_data is my original session. The other three blank sessions