session code in class problem

From: Date: Thu, 20 Jun 2002 15:48:02 +0000
Subject: session code in class problem
Groups: php.general 
Request: Send a blank email to php-general+get-103156@lists.php.net to get a copy of this message
I have the following .php script and .inc file which doesn't work: ===== .php file ===== <?PHP // Include function files require_once "includefiles/session_functions.inc"; // Create instances of the required class $sess = new Sessions; // chech for valid session $sess->Check_Session(); phpinfo(); ?> <html> <head> <title>Untitled</title> </head> <body> <table summary=""> <tr><td>admin</td></tr> </table> </body> </html> ===== .inc file ===== <?PHP class Sessions { function Check_Session() session_start(); if (!session_is_registered("SESSION")) { header("Location: http://???.???.??.?/index.php?logintext=Please login."); exit(); } } The session was created in a previous login script. When I enter the .php script I get the following error: Parse error: parse error, expecting `'{'' in /var/www/html/includefiles/session_functions.inc on line 7 Fatal error: Cannot instantiate non-existent class: sessions in /var/www/html/adminoutput.php on line 8 However, if I copy the code from the function in the .inc file and place it at the top of my php script, and delete the class code in the php script everything works OK. Why is this happening? I also tried placing session_start() in the php script before calling the class method Check_Session but this had no effect. Thanks in advance Mark **************************************************** This e-mail is intended for the recipient only and may contain confidential information. If you are not the intended recipient then you should reply to the sender and take no further ation based upon the content of the message. Internet e-mails are not necessarily secure and CCM Limited does not accept any responsibility for changes made to this message. Although checks have been made to ensure this message and any attchments are free from viruses the recipient should ensure that this is the case. ****************************************************

« previous php.general (#103156) next »