session-variables

PHP Session storing behavior into variables?

谁说我不能喝 提交于 2019-12-04 15:30:13
this is only happening in Chrome Has anyone ever experienced PHP sessions storing functional behavior into variables? I created the following script: <?php session_start(); $_SESSION['count'] = (isset($_SESSION['count'])) ? $_SESSION['count'] + 1 : 0; echo $_SESSION['count']; ?> You'd think this would echo 0, 1, 2, 3, etc. on each page load. However, I'm getting 1, 3, 5, 7, and so on. I found out that for some reason, $_SESSION['count'] acts as though its incrementing behavior has been stored within the variable. The reason it seems to increase by two on each page load is because when $

How can I determine the memory footprint of a session variable?

假装没事ソ 提交于 2019-12-04 15:00:23
Also, web.config - please explain. <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="120"/> We are using inproc mode and we used the 20 session variable in our web application. We need to know each variables Occupying the memory spaces. From George Shepherd's ASP.NET FAQ at http://www.syncfusion.com/faq/aspnet/web_c9c.aspx 36.37 Is there any way to know how much memory is being used by session variables in my application? No However, you can make an educated guess. The number

Understand “current_user” concept when creating a login session in ruby

风流意气都作罢 提交于 2019-12-04 14:37:05
问题 I am going through the great Michael Hartl tutorial to build ruby app here. I am trying to understand the concept of how to create a session and I am stuck in understanding this line: self.current_user = user in this method: module SessionsHelper def sign_in(user) cookies.permanent[:remember_token] = user.remember_token self.current_user = user end end I understand the whole concept of creating a cookie with the user_token. But I don't understand what does self.current_user = user means and

array_replace() / array_merge() | ( $_SESSION = array() ) argument is not an array?

怎甘沉沦 提交于 2019-12-04 14:11:15
I have this code for my school project and thought the code does its job on what i wanted it to do, i still keep on getting the error about $_SESSION[] is not an array argument when using the array_replace() and array_merge() functions: Session is already initiated on the header: // Start Session session_start(); For initialising the $_SESSION['cart'] as an array: // Parent array of all items, initialized if not already... if (!isset($_SESSION['cart'])) { $_SESSION['cart'] = array(); } For adding products from a dropdown menu: - (Just to see how the session is assigned:) if (isset($_POST['new

PHP: How to check if user is already logged in and otherwise redirect to login page

僤鯓⒐⒋嵵緔 提交于 2019-12-04 13:14:14
问题 I am new to PHP and am struggling with the following: I have a page where I want to check if someone is a registered user before letting them see the content of the site. So my thought was that in my header file (which is referenced on all single pages via require_once("includes/header.php"); ) I can check on that and redirect them to a login page ( login.php ) if they have not logged yet. So here is everything that I have in my header: <!DOCTYPE html> <html> <head> <?php define(

Facebook Login using HybridAuth showing error You cannot access this page directly

核能气质少年 提交于 2019-12-04 11:30:18
I am trying to write a plugin for my website to connect with facebook using the HybridAuth classes. I just tried following code function authenticatewith( $provider ) { ini_set('display_errors','on'); //includes $config = dirname(__FILE__) . '/hybridauth-2.1.2/hybridauth/config.php'; require_once("hybridauth-2.1.2/hybridauth/Hybrid/Auth.php"); $provider_name = $provider; //$config = $this->getconfig($id); try { // initialize Hybrid_Auth with a given file $hybridauth = new Hybrid_Auth($config); // try to authenticate with the selected provider $adapter = $hybridauth->authenticate($provider_name

How to prevent Cross-site request forgery (CSRF) effectively in PHP

半世苍凉 提交于 2019-12-04 11:26:56
问题 I am trying to prevent CSRF in php in the following way: A $_SESSION['token'] is generated at the start of each page. I already know that using $_COOKIES is completely wrong since they are send automatically for each request. In each <form> , the following input: <input type="hidden" name="t" value="<?php echo '$_SESSION['token']; ?>"> is appended. The $_SESSION['token']; is validated with the $_POST['t'] Now I have several small questions: Is this a good way to prevent CSRF? If not please

Session Best Practices

非 Y 不嫁゛ 提交于 2019-12-04 11:21:55
Hi I use Sessions in my application and I was wondering what is the best practice for maintaining session value on a page. I need the value that is stored in the session to be saved until the post back on a particular page. Let me illustrate: Page A: Page B: Sets Session["ID"] = 5 --> Gets Session["ID"] And redirects to Page B and populates data. I need the Session["ID"] on Page B to stay alive until a post back is performed on Page B. I need this because I will be using the value of Session["ID"] update data in the database. My question is: Is the any guarantee that the Session["ID"] will

session variables lost for some reason

夙愿已清 提交于 2019-12-04 09:46:40
问题 I try to setup a E-shop. Next to every item I've an asp:imagebutton when this imagebutton is clicked I'm checking whehter the session varialbe session["basket"] exists or not if not then I add the values in a list (entity class) and I add this list in the session. if the session is not empty then I retrieve the values from session into List and change the list and then add the list back to session. Issue: For some reason I loose the session variable, suddenly. I checked on my watch (time) and

Storing conversation of a specific user temporarily

自闭症网瘾萝莉.ら 提交于 2019-12-04 09:25:24
I tried using IActivityLogger to capture the conversation of a user, is there a way to compile the conversation of the user and the bot to a temporary holder like a variable or session? I need to temporarily store it somewhere that is readily available only when the user wants to talk to a real person instead of a bot. An email containing the previous conversation of the user and the bot will be sent. I don't want to save it to a DB since some user will not opt to do so. See Codes used. Logger Class: public class Logger:IActivityLogger { public async Task LogAsync(IActivity activity) { var a =