CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Session Vars, UserID not available

Print topic Send  topic

Author Message
Paul Wolsink
Posted: 08/27/2004, 2:40 AM

Hi There

I have a really weird problem and I'm not sure whether it is something I need to "fix" with Studio or the server.
I have looked all over this forum as well as other forums dedicated to PHP/Linux, etc.

After building an App with Studio using the Wizard builder, the app is working 100% on the Development server, but fails on the Production Server.

Problem:
--------
UserID is not getting set on the production server, but it does on development server.


UserID variables not available for authentication and not written to session files.
That is for the pages which need loging in.
Pages where I do not need to login in, I get an error 404 "The page cannot be displayed...page is currently unavailable"

I have a fairly standard LAMP environment on two different servers.

1. Development is a Compaq ML350
Hardware Intel
Linux stripples.devel.redhat.com 2.4.18-11 (e-Smith/Mitel standard v5.6)
Apache 1.3.23
MySQL 3.23.49
PHP 4.1.2


2. Production Sparc Sun microsystems
Hardware Sparc
Linux sparc-suse-linux - Linux peraine 2.4.9 (Suse 7.1 I think)
Apache 1.3.20
MySQL 3.23.44
PHP v4.0.6

Application identical on both servers with same mySQL connection setup, etc.
mySQL database is "mi" , login is "www" and password is none.
Structure and data exactly the same. (I copied from development server to production and triple checked)

I can access mySQL with user www manually and through scripts.


Development Server:
If I access the Login page, I get a session variable, but it is not written to /tmp immediately.
If I enter loginname/Password and it is incorrect, I immediately get a response Incorrect Loginname/Password combination.
If I enter loginname/password and it is correct, I get the login page returned as it should and then I can click on another page link and it works beautifully. The session file is written to /tmp with the proper content ie:
#ls -all
---cut----
-rw------- 1 www www 60 Aug 26 12:31 sess_aae8f4b400674d449d05a5559b626229
---cut----
#cat sess_aae8f4b400674d449d05a5559b626229
UserID|s:1:"1";UserLogin|s:4:"paul";GroupID|s:1:"1";

BUT THEN:
Production Server:
EXACTLY the same App with absolutely no changes made.
If I access the Login page, I get a session variable, but it is not written to /tmp immediately.
If I enter loginname/Password and it is incorrect, I get >>NO<< response that Loginname/Password combination is incorrect.
I get bumped back to the Login page as if nothing happened.(like you entered everything correctly)
If I enter loginname/password and it is correct, I get the login page returned as it should and then I can click on another link and it DOES NOT work. The session file is written to /tmp with the UserID, etc missing ie:

Result:
#ls -all
--cut--
-rw------- 1 www www 0 Aug 26 13:01 sess_00e550710676f6b4ab2d116c05b7e84e
--cut--

#cat sess_00e550710676f6b4ab2d116c05b7e84e


#

NOW I went troubleshooting:
I created a Page test.php in Studio with only header etc and Hello World and it worked fine.
I added the following somewhere in the middle:

---cut here----
echo("sessie1=");
print(session_id());
session_start();
print("<br>");
session_register('MYUser');
print($UserID."<br>");
session_save_path();
print(session_save_path()."<br>");
mysql_connect('localhost','www','');
mysql_select_db('mi');
$resultaat=mysql_query("SELECT member_id,loginnaam FROM member ");
$record = mysql_fetch_assoc($resultaat);
echo("{$record['member_id']} {$record['loginnaam']}");
$UserID = $member_id;
print($UserID."<br>");

----end cut----


If I access this page from same browser session, the following is written to session file in /tmp.
NOTE: Only the manually create session variable and not thiose from Studio.

#ls -all
--cut--
-rw------- 1 www www 8 Aug 26 13:01 sess_
--cut--

#cat sess_00e550710676f6b4ab2d116c05b7e84e
!MYUser|

Results on screen have added that to my test.php:
Developments Server:
--------------------
sessie1=aae8f4b400674d449d05a5559b626229
1
/tmp
1paul
---------------------------------------
Production Server
-----------------
sessie1=00e550710676f6b4ab2d116c05b7e84e

/tmp
paul
--------------------------------------

Even the UserID = Member_id becomes/stays blank.


I can write to the mySQL database as I import data into the database with a PHP script which runs under crontab from a scripts folder.

I think/know that the /tmp folder has the correct access rights as well as the user under which Apache runs.(User www and group www)
#ls -all
drwxrwxrwt 5 root root 512 Aug 26 13:32 tmp

Conclusion:
-----------
From the above fault finding I can see that:
1. something is written to the session file (Access OK)
2. session variables can be created, read, session path is /tmp
3. User rights on Database/Table is OK as I can write and read as this user from Localhost
4. Folder from which scripts/app runs is OK as well as all scripts run fine.


Question:
What else do I check?
I am totally lost!

greetings
Paul

Paul Wolsink
Posted: 08/27/2004, 2:47 AM

Sorry one small correction.
There should be a 1 in front of the name paul.

Production Server
-----------------
sessie1=00e550710676f6b4ab2d116c05b7e84e

/tmp
1paul
--------------------------------------
Oper


Posts: 1195
Posted: 08/27/2004, 7:32 AM

Check your Browse Cookie (enable or Disable)

just thought (look odd so)
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
Paul Wolsink
Posted: 08/28/2004, 9:54 AM

Hi there
That was one of the first things I checked just to be sure, but that made no diff.
Oper


Posts: 1195
Posted: 08/28/2004, 4:15 PM

let see.
maybe you using last version 2.3.2.24
and you editing a Project already done with prior version and
you forget to generate all Commons files?

ANother guess...

_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)

http://www.PremiumWebTemplate.com
Affiliation Web Site Templates

Please do backup first
View profile  Send private message
peterr


Posts: 5971
Posted: 08/29/2004, 3:49 AM

Paul,

Do both databases contain exact same users, including same GroupID for each user?

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Paul Wolsink
Posted: 08/30/2004, 2:32 AM

Hi Open and peterr

I created the app (brand new!) with the same version and uploaded. There was no diff. between Studio version numbers. I also deleten everything in the app folder and re-published, made no difference.

Both databases exact the same. I created the database on the production machine and imported loads of data with PHP scripts, exported with mysqlfront to the development machine without data, (except two tables just to have some data).
I then created 2x users on the development machine and also manually on de production machine but had the problem. To be sure, I exported the members database from development machine where it worked with drop table to production machine. Thus exact copy on prod. machine as on dev. machine.
Still doesn't work.

really weird.

Just an update: I installed the App without any changes except for the connection to database to another production server (Intel, Linux RedHat7.3) connecting to the mySQL database on the original server and it's working like a charm. I therefore now know for sure it is not the Database (MySQL)
Must be some combination SuSe/Sparc/PHP setup or "maybe" some rights on folders which I'm missing, althought it appears correct.

regards
Paul
peterr


Posts: 5971
Posted: 08/30/2004, 11:06 AM

Paul,

Not sure how else to help you. You could ask our support to look at your server, if you want to let us in.
Otherwise maybe try to create a small PHP program witout CCS to test your sessions.
CCS login consists of couple standard PHP functions that create sessions, therefore I suspect that the problem is generic and not specific only to CCS. If you are able to confirm this then you can tackle this problem by searching Google and Google Groups. There are millions of PHP-related posts and resource and it's likely that others experienced the same problem and solved it.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Paul Wolsink
Posted: 08/30/2004, 11:58 PM

Hi peterr
I've tried the sessions thing as you described in the test.php in my original post. That worked, but the session variables from Studio app doesn't.
Searching on Google just explain the common errors like make sure your rights in the /tmp directory is set , etc.
I think it is a weird combination the way Studio write a session variable and the way I did in the test.php.
I should dive into Studio code, or let it run on the second production server or just install a dedicatated webserver just for this app and let the database stay on the Suse machine. In the long run easier and cheaper than to spend hours.

thanks
Paul
peterr


Posts: 5971
Posted: 08/31/2004, 12:32 AM

Paul, hi again,

I think that there is only one way to create sessions in PHP, and below is the full code that CCS uses to create them in Common.php:
function CCSetSession($param_name, $param_value)  
{  
    $_SESSION[$param_name] = $param_value;  
}  
...  
function CCLoginUser($login, $password)  
{  
    $db = new clsDBIntranetDB();  
    $SQL = "SELECT emp_id, group_id FROM employees WHERE emp_login=" . $db->ToSQL($login, ccsText) . " AND emp_password=" . $db->ToSQL($password, ccsText);  
    $db->query($SQL);  
    $Result = $db->next_record();  
    if($Result)  
    {  
        CCSetSession("UserID", $db->f("emp_id"));  
        CCSetSession("UserLogin", $login);  
        CCSetSession("GroupID", $db->f("group_id"));  
    }  
    $db->close();  
    return $Result;  
}

Looks quite straightforward.
If this doesn't work then likely the problem is with the database. Possibly the GroupID is not being read correctly or not at all.
Try placing the 'echo' command in the above code in Common.php and display the database values: $login, $db->f("emp_id"), $db->f("group_id").
This should be the simplest debugging method.

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Justman
Posted: 09/11/2004, 1:58 AM

Hi Peter,

I am experiencing similar session issues that Paul reported above.

Although I am using Windows 2003 Server + IIS.6.0 + PHP 5.0 which is different from Paul's environment.

I have tried your suggestions above but it didn't work. I am wondering if you have come across more ideas on how to get Session variables with CCS generated code.

Cheers
Justman
peterr


Posts: 5971
Posted: 09/11/2004, 10:25 AM

Hi,

There could be many reasons for such problem. I suspect that Paul's problem was more complex and unusual, but most of the time these problems are quite basic. It would be best if you described the exact symptoms of your problem. The most common issues are with cookies, or lack of temporary folder specified in PHP.ini. Take a look at this post:
http://forums.codecharge.com/posts.php?post_id=49218
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.