PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, November 12, 2022

[FIXED] How to use Memcache session in php gae

 November 12, 2022     google-app-engine, memcached, php, session, variables     No comments   

Issue

I was wondering if any one could teach me how to use sessions in GAE php. I know that the usual method is to use session_start() in every page that wants the session to carry over and then assign variables using $_SESSION['name'].

But PHP on GAE is a bit confusing at times.

https://developers.google.com/appengine/docs/php/?hl=en#Sessions

I have some idea on memcache but dont know how to use it to store session variable. Can any one tell how I can create a session variable so that when I redirect using header the variables will be present too.

Eg.

First.php

session_start();
$_SESSION['name'] = Abilash;

header('location: second.php');

Second.php

session_start(); echo $_SESSION['name']; // should output Abilash.

Now how do I do that in GAE. Whenever I try to redirect using header the redirected page loads but the session variables are not passed through.


Solution

You should not need to do anything to get sessions working, as we automatically put them into memcache by default.

Perhaps the session cookie is not being passed by your browser for the second request. I'd turn on developer tools in chrome to make sure you see that the cookie is on the request and I'd also output the result of session_start() to check it's returning true.



Answered By - Stuart Langley
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing