LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-22-2021, 05:05 PM   #1
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Rep: Reputation: Disabled
Session vars


All,

Hate to trouble you but have this code:

Code:
	session_name	( 'bizlist'	);
	session_start	( 'bizlist'	);
	$dbtst	=	tst_db ();
Calling this function:

Code:
function tst_db () {
	$em_dir	= "/mypath/EM/em_dio";
	include_once (	"$em_dir/em_dio.php" );
	define	(	'DB_USE', 'biz_track' );
	$_SESSION ['DB'] = DB_USE;
	define	'EM_DIR', "$em_dir" );
	$_SESSION ['EM_DIR'] = $em_dir;
	echo "ED=> $emdir SD=> $_SESSION ['EM_DIR'] !";
	$edb	=	new em_dio();
	$cont	=	$edb->dbConnect($_SESSION['DB']);
	$tstdb	=	$edb->dbTest($_SESSION['DB']);
	if ( $tstdb==1 ) {
	   echo "DB Connected and Ready! ";
	   return 1;
	} else {
	   echo "Adding the DB!";
	   //'mysql -u $USER -pmypass' < 'deffile.sql';
	   //$dbtst	=	tst_db ();			
	   return $dbtst;
	}  // end if mysql_num_rows		
}	// end function tst-db
but somehow the $_SESSION vars are not being enabled. Sorry have forgotten the HOWTO troubleshoot this scenario, so all help appreciated!

This function is to test and make sure the MySQL DB exists and is enabled and if not add it to enable processing!

Thnx!

TBNK
 
Old 06-23-2021, 12:49 AM   #2
lvm_
Member
 
Registered: Jul 2020
Posts: 925

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
What of the zillion programming languages is this - php? If yes, I believe session_start expects options, not session name as a parameter. Check whether the session is created successfully - whether session_start retuned true.
 
Old 06-23-2021, 08:38 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Also, be sure that you fully understand what "sessions" are, how they work, and how they are implemented.

Until you are absolutely clear on what is actually going on – when, and why – it can indeed be very confusing! So, let me try to explain:

A "session" is a host-side place where variable values can be stored between one HTTP request and the next. Once the session has been established on the host, the (random ...) "session-id" is communicated to the client side by means of an HTTP "cookie." In this way, it will be included in each subsequent request. Either the programming language or the web-site software takes care of the chore of making the session-variables available to you, and for storing the new values back in the persistent storage-area at the end of the request.
 
Old 06-23-2021, 10:13 AM   #4
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
LVM & Sundialsvcs,

I know what sessions are and how to use them having used them thousands of times and have over 1 million lines of code written using them. That is why I can't understand why they are not working now. I'm using them on 2 CPUs 1.) Kubuntu 14.04 LTS, 2.) Kubuntu 18.04 LTS.

These calls are originating in the Enterprise Modules Framework, that I designed originally in 1994 and use on almost every PHP project I use/build since then, with over 2,000 projects completed deployed at over 5,000 companies, with no current errors; and now starting a new "data capture" project now.

The "em-dio.php" object (named for Enterprise Modules Data I/O) allows the seamless capture, exchange & transfer of data in any DB engine (yes all DB engines and all their calls work in this module). The "em-objects.php" initializes all the 32 plus EM Objects. Of course all are written to be compiled as PHP is 100% compilable!

If you had looked up the PHP docs at:

https://www.php.net/manual/en/reserv...es.session.php

You would know I'm correctly calling session_start. I still get the errors even without declaring the session name. Knowing your security for PHP you know you have to turn "globals" off, so sessions is the only secure way to share variables information between PHP files/modules you are using.

"em-obects.php" is this initiating code:

Code:
<?php
   /***************************************************************************/
   /* Classes: Analysis:		em_analy,		Archive:			em_archv,			*/
   /*          Array Proc.		em_aproc,		Audit:			em_audit,			*/
   /*          Communication:	em_comms,		Data Format:	em_datfm,			*/
   /*          Data I/O:		em_datio,		Drivers(HAL):	em_haldv,			*/
   /*				En/Decrypt,    em_crypt,		File System:	em_flsys,       	*/
   /*          Logic:			em_logic,		Math Basic,		em_bmath,			*/
   /*          Math Advanced,	em_amath,		Networking:		em_netwk,			*/
   /*          Notification	em_notif,		Scheduling,		em_sched,			*/
   /*          Show:				em_dshow,		Security:		em_secur,			*/
   /*				Standard I/O:	em_stdio,		Synching:		em_synch,			*/		
   /*				Translation:	em_trans,		Virtualization em_vertz.			*/
   /***************************************************************************/
   /*   Notes: Enterprise Modules only uses the "Advanced Documentation       */
   /*          Standard, which is shown here. Please following this std.      */
   /*          when submitting extensions and enhancement to EM.					*/
   /***************************************************************************/
   /*   Notes: The class modules for modularization purposes are only linked  */
   /*          but not contained here.                                        */
   /***************************************************************************/
   /*  Mod by: Nyle E. Davis             Mod Date: 18-03-06                   */
   /*  Change: Class Adds                                                     */
   /*  Desc:   The original 24 EM modules are documented above, but over time */
   /*          it was seen that these additional modules were needed.  At the	*/
   /*          time of entry of this comment there are now 36 modules.			*/
   /*          Adv Arrays:		em_adray,		Backup:			em_bckup,			*/
   /*          Collaboration,	em_collb,		Development:	em_devlp,			*/
   /*				Engineering:	em_engfc,		Flow:				em_flows,			*/
   /*				GIS,				em_ginfo,		Media,			em_media,			*/
   /*				Presentation:	em_prest,		Rendering:		em_rendr,			*/  
   /*				Streaming:		em_strem,		Ver Control:	em_versc,			*/  
   /***************************************************************************/
   /*  Mod by: Nyle E. Davis             Mod Date: 18-03-10                   */
   /*  Change: MVC Adds	                                                      */
   /*  Desc:   Added abstract classes to allow MVC processing for Enterprise	*/
   /*          Modules.											`								*/
   /***************************************************************************/
	//define ( 'PRUN_ME', 1 );
	session_start	( 	);
   include_once ('em_aproc/em_adray.php');		// Advanced Array Funtions
   include_once ('em_analy/em_analy.php');		// Analisys/Analytics Funtions
   include_once ('em_aproc/em_aproc.php');		//	Array Processing Functions
   include_once ('em_archv/em_archv.php');		//	Archive/Compression Functions
   include_once ('em_audit/em_audit.php');		// Audit Functions
   include_once ('em_bckup/em_bckup.php');		// Backup/Disaster Recovery Functions
   include_once ('em_collb/em_collb.php');		// Collaberation Functions
   include_once ('em_comms/em_comms.php');		// Communitcation Functions
   include_once ('em_crypt/em_crypt.php');		// EnCrypt/DeCrypt Functions
   include_once ('em_datfm/em_datfm.php');		// Data Format Functions
   include_once ('em_dio/em_dio.php');		        // Data I/O Functions
   include_once ('em_devlp/em_devlp.php');		// Development Functions
   include_once ('em_dshow/em_dshow.php');		// Display/Show Functions
   include_once ('em_engfc/em_engfc.php');		// Engineering Functions
   include_once ('em_flows/em_flows.php');		// Functions for Flows
   include_once ('em_flsys/em_flsys.php');		// File System Functions
   include_once ('em_ginfo/em_ginfo.php');		// GIS Functions
   include_once ('em_haldv/em_haldv.php');		// Driver Functions
   include_once ('em_langs/em_langs.php');		// Languages Functions
   include_once ('em_logic/em_logic.php');		// Logic Functions
   include_once ('em_maths/em_amath.php');		// Advanced Math Funtions
   include_once ('em_maths/em_bmath.php');		// Basic Math Functions
   include_once ('em_media/em_media.php');		// Media Functions
   include_once ('em_model/em_model.php');		// Modeling Functions
   include_once ('em_netwk/em_netwk.php');		// Networking Functions
   include_once ('em_notif/em_notif.php');		// Notification Functions
   include_once ('em_rendr/em_rendr.php');		// Rendering Functions
   include_once ('em_sched/em_sched.php');		// Scheduling Functions
   include_once ('em_secur/em_secur.php');		// Security Functions
   include_once ('em_seopr/em_seopr.php');		// SEO Proc Functions
   include_once ('em_stdio/em_stdio.php');		// Standard I/O Functions
   include_once ('em_strem/em_strem.php');		// Streaming Functions
   include_once ('em_synch/em_synch.php');		// Synchronization Functions
   include_once ('em_trans/em_trans.php');		// Translation Functions
   include_once ('em_vectr/em_vectr.php');		// Vectoring Functions
   include_once ('em_versn/em_versn.php');		// Version Control Functions
   include_once ('em_virtl/em_virtl.php');		// Virtualization Functions

   // Declarce Modules
   class em_modules {
		/************************************************************************/
		/*  Author: Nyle E. Davis             Mod Date: 18-03-10						*/
		/*  Desc:   Declare the Emterprise Modules.										*/
		/************************************************************************/
		
      function __construct() {
			/*********************************************************************/
			/*  Author: Nyle E. Davis             Mod Date: 18-03-10 				*/
			/*  Desc:   Open  the Emterprise Modules.									*/
			/*********************************************************************/
			$em_modules				=	new em_modules();
			//	Reserved for adding individual models
      }     // end function __construct
   }   // end class em_modules

   abstract class em_mvc_model {
		/************************************************************************/
		/*  Author: Nyle E. Davis             Mod Date: 18-03-10						*/
		/*  Desc:   Declare the Emterprics Module MVC Model method.				*/
		/************************************************************************/

      function __construct() {
			/*********************************************************************/
			/*  Author: Nyle E. Davis             Mod Date: 18-03-10 				*/
			/*  Desc:   Open  the Emterprise Module MVC Model method.				*/
			/*********************************************************************/
			$em_mvc_model			=	new em_mvc_model();
			//	Reserved for adding individual models
      }     // end function __construct
   }   // end class em_mvc_model

   abstract class em_mvc_viewer {
		/************************************************************************/
		/*  Author: Nyle E. Davis             Mod Date: 18-03-10						*/
		/*  Desc:   Declare the Emterprise Module MVC Viewer method.				*/
		/************************************************************************/

      function __construct() {
			/*********************************************************************/
			/*  Author: Nyle E. Davis             Mod Date: 18-03-10 				*/
			/*  Desc:   Open  the Emterprise Module MVC Viewer method.				*/
			/*********************************************************************/
			$em_mvc_viewer			=	new em_mvc_viewer();
			//	Reserved for adding individual models
      }     // end function __construct
   }   // end class em_mvc_viewer

   abstract class em_mvc_controller {
		/************************************************************************/
		/*  Author: Nyle E. Davis             Mod Date: 18-03-10						*/
		/*  Desc:   Declare the Emterprise Module MVC Controller method.			*/
		/************************************************************************/

      function __construct() {
			/*********************************************************************/
			/*  Author: Nyle E. Davis             Mod Date: 18-03-10 				*/
			/*  Desc:   Open  the Emterprise Module MVC Controller method.			*/
			/*********************************************************************/
			$em_mvc_controller	=	new em_mvc_controller();
			//	Reserved for adding individual models
      }     // end function __construct
   }   // end class em_mvc_controller
?>
All this code has been in use, without errors since inception and installed at over 5,000 companies we have supported for processing.

So now back to the question: Why is it not working now? I've been having Apache issues on the 18.04 LTS machine, so was developing on the 14.04 LTS machine.

I'm currently using cmd line for testing, but expect to be in the browser with final completion of the "screen" module. Getting these errors:

Code:
PHP Notice:  A session had already been started - ignoring session_start() in /Syncs/Projects/EM/em_dio/em_dio.php on line 36
<pre>array(0) {
}
</pre>
PHP Notice:  Undefined variable: emdir in /Syncs/Projects/EM/em_dio/em_dio.php on line 45
ED=>  !PHP Notice:  Undefined variable: emdir in /Syncs/Projects/EM/em_dio/em_dio.php on line 46
PHP Warning:  include_once(/em_objects.php): failed to open stream: No such file or directory in /Syncs/Projects/EM/em_dio/em_dio.php on line 46
PHP Warning:  include_once(): Failed opening '/em_objects.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /Syncs/Projects/EM/em_dio/em_dio.php on line 46
PHP Fatal error:  Class 'em_modules' not found in /Syncs/Projects/EM/em_dio/em_dio.php on line 48
The latter errors are obvious, since the var "emdir" does not get set, the path to the file being called is the default path, not the declared path, thus those errors are caused by the path not being properly defined.

Now if you think I have a PHP config issue, which I suspect, let me know. Open to any other ideas also!

TBNK

Last edited by TBotNik; 06-23-2021 at 10:28 AM.
 
Old 06-24-2021, 10:22 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Quote:
I'm currently using cmd line for testing
em-obects.php does start a session but since your test script has already started a session you see the "A session had already been started" error message. A session is created when using the command line but when starting a new session you need the old session ID to use the previously stored values. As posted sessions is a way to store information used across web pages not files/functions. When calling functions via the command line your back in the real world of variable scope.
 
Old 06-25-2021, 12:12 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by TBotNik View Post
I know what sessions are and how to use them having used them thousands of times and have over 1 million lines of code written using them. That is why I can't understand why they are not working now. I'm using them on 2 CPUs 1.) Kubuntu 14.04 LTS, 2.) Kubuntu 18.04 LTS.

These calls are originating in the Enterprise Modules Framework, that I designed originally in 1994 and use on almost every PHP project I use/build since then, with over 2,000 projects completed deployed at over 5,000 companies, with no current errors; and now starting a new "data capture" project now.
Well then you should be able to at least formulate a proper question with all required information and initial troubleshooting steps.
Or maybe your claims should be taken wtih a pinch of salt?

Also, are you running your servers of Kubuntu machines, i.e. desktop installs??? One of them EOL???
 
Old 06-25-2021, 10:16 AM   #7
TBotNik
Member
 
Registered: May 2016
Location: Greenville, TX
Distribution: Kubuntu 18.04
Posts: 796

Original Poster
Rep: Reputation: Disabled
All,

Found my issue! Was starting the session and assigning the vars in a function, which by PHP rules make them only local to that function.

Moved these code lines outside the function, so they could be public and then things started working.

Still have some minor errors, but now manageable! Will marked "Solved" when I finish the debugging!

Cheers!

TBNK
 
  


Reply

Tags
mysql, php, script, sessions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to launch "cinnamon-session-cinnamon" X session "cinnamon-session-cinnamon" -found; Falling back to default "session." xxxindigo Linux Mint 22 09-01-2019 09:21 AM
Session key renegotiation if session lasts longer than configured (e.g. an hour) then session keys needs to be renegotiated. dakshinya Linux - Newbie 1 02-04-2016 04:15 PM
Environment vars AMDPwred Linux - General 2 02-28-2003 07:11 AM
slooze error: validateInputs(); $msg = $mySlooze->renderPage($vars); echo $msg; ?> rioguia Linux - Software 0 01-26-2003 08:59 PM
Missing $_SERVER vars in php4.3 ?? chr15t0 Linux - General 0 12-10-2002 10:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration