Re: Problem with variables
| From: | Jim Giner | Date: | Tue, 25 Jun 2013 22:15:38 +0000 |
| Subject: | Re: Problem with variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-321494@lists.php.net to get a copy of this message | ||
On 6/25/2013 5:46 PM, Fernando A wrote:
Hello, I am working with php and codeigniter, but I have not yet experienced. I need create a variable that is available throughout system. This variable contains the number of company and can change. as I can handle this? Thank you, very much! Ferd One way would be to create a file like this:<? // company_info.php $_SESSION['company_name'] = "My Company"; $_SESSION['company_addr1'] = "1 Main St."; etc. etc. etc. Then - in your startup script (or in every script), use an include statement: <?php session_start(); include($path_to_includes."/company_info.php"); Now you will have those SESSION vars available for the entire session, basically until you close your browser. You can also use the php.ini auto-prepend setting, which automatically does this for you, altho the vars would not be session vars, since the prepend-ed file happens before your script issues the session_start (I think).