Session variables from another PHP program...

Discuss phpwcms here, please do not post support requests, bug reports, or feature requests! Non-phpwcms questions, discussion goes in General Chat!
Post Reply
Will
Posts: 55
Joined: Mon 9. Aug 2004, 05:30

Session variables from another PHP program...

Post 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,
Will
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Post 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...
:)
Will
Posts: 55
Joined: Mon 9. Aug 2004, 05:30

Post by Will »

Thanks! Yes, it solved my problem.

All best,
Will
Will
Post Reply