Page 1 of 1

Session variables from another PHP program...

Posted: Wed 6. Jul 2005, 23:18
by Will
Hello,

I made a php program which will allows my customers to see some information from my backoffice application. The main db resides in my office and a replicated db is dumped twice a week to the webserver.

So far so good. Now, I want to show my customers a login box in the frontend (done already), BUT I would like that if they get into the program and then they browse the rest of my phpwcms site (without login-out the php program), they could see a nice text (like Welcome Mr. Smith!) instead of the login box.

I tried to made the following changes in my phpwcms templates with no sucess (it seems that phpwcms use another session id):

(not exactly the following code... it is not a copy&paste... it's just what I can remember right now)
[PHP]

if ($_SESSION["smile_username"]) {
echo "Welcome! <a href="URL_TO_MY_PHP_PROGRAM">Get in!</a>";
} else {
// printing the login box.
}

[/PHP]

I think I could make it if I could somehow save my sessionid into the phpwcms session... Is it possible? How in earth?

TIA,

Posted: Tue 26. Jul 2005, 15:36
by jsw_nz
Hi Will,

If you are using the dev versions of wcms, don't forget the session_name parameter:

session_name('hashID');
session_start();

I had formerly deved a custom session app in earlier versions of wcms, where session_name was not declared in index.php....once I upgraded to newest version...i needed to declare this to get the scripts working.

One idea in debugging is to place:

echo "<pre>";
print_r($_SESSION);
print_r($_POST);
echo "</pre>";

where you think it appropriate....for tracking
just a couple of ideas..
not sure if they are any help...
:)

Posted: Tue 26. Jul 2005, 19:07
by Will
Thanks! Yes, it solved my problem.

All best,
Will