1
Hello everyone,
This is my first post in the forum. If I placed my question in the wrong place, pardon, si vous plait.
I am trying to integrate my own php scripts with XOOPS-2-0-18-1. What I did was.
1. place my scripts into a folder in the XOOPS folder, where XOOPS is installed.
2. add the snippet.
include("../mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
?>
at the beginning of my own script
3. add the snippt.
include(XOOPS_ROOT_PATH."/footer.php");
?>
at the end of my script.
I get the same look & feel executing my scripts as well as the rest of the XOOPS content.
Now, in my own script, I use php session to pass data, while user navigating through pages. Within my own scripts, my session is handled in the following way.
function register($name, $val)
{
if (!isset($_SESSION))
{
session_start();
}
$_SESSION[$name] = $val;
}
function retrive($name)
{
if (!isset($_SESSION))
{
session_start();
}
if (isset($_SESSION[$name]))
{
return $_SESSION[$name];
}
else
{
return null;
}
}
Notice that I do not store class or object, or anything fancy along that line into my session. These functions are used to store and retrive simple name and value pairs.
After integrated my application with XOOPS as a whole site, I performed testing on two local php environments (both are packaged in xampp), php 5.1.1 and php 5.2.5. The whole site works perfectly fine.
However, when I deployed this same application on my hosting server (php 4.4.8). It seems that in my own scripts, the session data is not preserved, while a user navigating through these pages.
If I add a php script block
session_start();
?>
at the very first line of my script, that is, before the
include("../mainfile.php");
include(XOOPS_ROOT_PATH."/header.php");
?>
when the user navigate to my php script, a new session will be created. And as long as the user is navigating within the scope of my own application, session data that is managed by my own php scripts can be stored and retrived perfectly fine. In other words, at this point, the session that was created in the XOOPS site (for example, after user logged in, the uid, group info are stored in this session) is not available. Then, as soon as the user navigate outside of my application scope, the XOOPS site session is again available, but the session created within my script is not available.
The only session configuration difference between my local and my host environments that I spotted is that my local uses "files user sqlite" as "Registered save handlers", while my host uses "files user". I have already asked my host to investigate whether that makes any difference.
Other than that, can someone here tell me whether there is a build in session management mechanism that I can safely make use of. Or any suggestion what I had done wrong with my own session usage in my code?
BTW, I had done search home work, no success in finding a solution.
Many thanks for your assistance. Merci a tous.