ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi. I have a script that assigns an object to a session variable. At the end of the script I var_dump the variable to the effect expected. But the session variable doesn't appear in the file where session variables are stored on the server. I want to use the object when the page reloads, but since it's not registered I can't use it. I would include the code but it involves several files including homemade class files. Help will be appreciated.
Remember that you must update the persistent session-variable store at the conclusion of your HTTP transaction. No matter what language you are using, there will be some required protocol for handling this requirement.
During the next HTTP transaction, whenever it may be, the session-identifier (however it may be passed) will be used as a key to retrieve the session-variables pool from wherever it gets stored in your scenario. If you don't see the values changing, it's a dead giveaway that the values aren't being re-posted to whatever that persistent store is.
Last edited by sundialsvcs; 12-12-2012 at 05:39 PM.
What do you mean by session variable? You don't have to paste your whole program, only a few lines,
Okay, this is my best shot:
Code:
<?php
session_start();
$_SESSION["firstname"]="Barth";
$_SESSION["lastname"]="Jones";
$_POST["password"]="circle7";
//trylogin is a function that returns an object if the login info is valid:
if(!empty($_GET["metadata1"]))if($_GET["metadata1"]=="virginloggingin") $_SESSION["youmember"]=trylogin($_SESSION["firstname"], $_SESSION["lastname"], md5($_POST["password"]));
//this works (it dumps the whole object):
var_dump($_SESSION["youmember"]);
//but when I reload this page after commenting out the trylogin line, var_dump returns null because $_SESSION["youmember"] wasn't written to the session file; when it's commented out, $firstname and $lastname are written to the session file, otherwise the session file is written, but empty
//not sure what's going on
?>
I think I figured it out. I failed to mention that my class returns a "simplexml" object, which I've now discovered can't be "serialized." I guess that also means it can't be written as a session variable. So I suppose I'll go back into my class and reconstruct the simplexml elements as some other kind of object. Thanks for your contributions.
Please carefully read sundial's post here (#3). I agree with his view that you must invoke the appropriate protocol to store this (persistent) information on the server. In my view, this would lie outside of the functionality of your class.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.