Global.asa
Moderator: General Moderators
Global.asa
Can any one tell me is there any thing like global.asa in php
I suspect that an include file is what you're looking for. All of your class, function, whatever you want, can be put into an included file and called whenever you need.
Just make sure that you give it a .php extension. The early practice in the PHP community was to use .inc to denote included files. The problem is that the server doesn't parse these files if they are called individually representing something of a security risk. Most servers can be configured to parse .inc file as php, however, most people just change the name of the files to .php.
Cheers,
BDKR
Just make sure that you give it a .php extension. The early practice in the PHP community was to use .inc to denote included files. The problem is that the server doesn't parse these files if they are called individually representing something of a security risk. Most servers can be configured to parse .inc file as php, however, most people just change the name of the files to .php.
Cheers,
BDKR
Actually, if you have access to your php.ini you could write a file that includes all of the files, classes, functions, etc that you want included in every php page and then set that file in the php.ini auto_prepend_file section like:
auto_prepend_file = "/usr/local/lib/php/myclasses.php"
or what have you...
auto_prepend_file = "/usr/local/lib/php/myclasses.php"
or what have you...
Well, done this way it's for all pages on the site. There is, I believe, a way to do it with certain directories only, using .htaccess or something, but I'm not sure how to do it. Maybe check the PHP web site and see if there is anything there about it...You COULD also, if it's available to you, use the CGI version of PHP which would make it so only YOUR files included it...
-
fractalvibes
- Forum Contributor
- Posts: 335
- Joined: Thu Sep 26, 2002 6:14 pm
- Location: Waco, Texas
global.asa
I don't think you will find an equivalent of global.asa. Much of the usefullness of that is being able to have certain events occur upon Session Start, Session End, Application Start, and Application End. You might can roll your own, but I think session handling may yet be a little immature in
PHP. That sort of function is the only reason I have ever used global.asa....otherwise I declare session variables as I need them...and sparingly.
Included files I think just provide a subset of that functionality. If you could find a way to trap the PHP equivalent of session start and session end, you might can mimic the global.asa.
Perhaps if you explain what you are needing to accomplish, a better focus on the solution might be had.
Phil J.
PHP. That sort of function is the only reason I have ever used global.asa....otherwise I declare session variables as I need them...and sparingly.
Included files I think just provide a subset of that functionality. If you could find a way to trap the PHP equivalent of session start and session end, you might can mimic the global.asa.
Perhaps if you explain what you are needing to accomplish, a better focus on the solution might be had.
Phil J.
I will agree with everyone that there is no equivalent to the Global.asa file in PHP, but the include file CAN be made to do whatever you want! So have at it. It seems like we spend too much time worrying about the lack of equivalents in various languages when we can just take what a language provides and create with it what we need.
As for this...
Cheers,
BDKR
As for this...
... in what way is PHP session handling immature?...I think session handling may yet be a little immature in PHP....
Cheers,
BDKR
-
fractalvibes
- Forum Contributor
- Posts: 335
- Joined: Thu Sep 26, 2002 6:14 pm
- Location: Waco, Texas
global.asa
I say that based upon my experience with PHP sessions. Perhaps it is actually a configuration issue - can't say since i don't host the site myself
1.) Don't know of any way to trap session.start, session.end, etc.
2.) Sometimes the session ID appears in the Address bar???
3.) Seems that session vars have to be declared in a special way to persist from page to page - declared as a global type of some sort...
4.) Seems that each page has to have a session_start command or previously declared session vars are unavailable in the page.
5.) Due to the above, sessions just do not operate as smoothly as in ASP, from my experiences. I am sure this will improve with each new release of PHP
Phil J.
1.) Don't know of any way to trap session.start, session.end, etc.
2.) Sometimes the session ID appears in the Address bar???
3.) Seems that session vars have to be declared in a special way to persist from page to page - declared as a global type of some sort...
4.) Seems that each page has to have a session_start command or previously declared session vars are unavailable in the page.
5.) Due to the above, sessions just do not operate as smoothly as in ASP, from my experiences. I am sure this will improve with each new release of PHP
Phil J.
I take the list as questions like "How can php ...."
- e.g. http://www.php.net/manual/en/function.s ... andler.php or by using the auto-include you can check wether a session-var is set or not; if not it's a new session and the var. is set
- sessions can be handled in two ways, either by storing the sessionid in a cookies or by appending the sessionid to the url. Php offers both, see http://www.php.net/manual/en/ref.sessio ... -trans_sid
- anything that can be casted to a string can be stored in $_SESSION, e.g. $_SESSION['user']='me'; and will available at the next page within the same session
- session.auto_start=On in php.ini (and/or .htaccess?) and your sessions will start without calling session_register, but each request will use sessions ...even if unnecessary
-
fractalvibes
- Forum Contributor
- Posts: 335
- Joined: Thu Sep 26, 2002 6:14 pm
- Location: Waco, Texas
Thanks for the info. I figured the session_start was a config issue.
Getting back around to the original issue - what was the initial poster wanting to do in a global.asa-like capacity?
No dissing of PHP intended by my remark - session functionality is a relatively new functionality of PHP and will no doubt keep improving.
Phil J.
Getting back around to the original issue - what was the initial poster wanting to do in a global.asa-like capacity?
No dissing of PHP intended by my remark - session functionality is a relatively new functionality of PHP and will no doubt keep improving.
Phil J.
Hey Phil,fractalvibes wrote:Thanks for the info. I figured the session_start was a config issue.
Getting back around to the original issue - what was the initial poster wanting to do in a global.asa-like capacity?
No dissing of PHP intended by my remark - session functionality is a relatively new functionality of PHP and will no doubt keep improving.
Phil J.
I myself didn't think you were dissin' PHP. I was just curious. Hope you didn't feel any heat from me as I wasn't intending as such.
Anyway, seeing as how Volka inserted $30.00 worth of fact there about sessions, I won't go on. Besides, I don't use PHP's session handling and prefer to store session data in a db with my own code. Much of this is a result of my feelings that if whatever site I create grows to a point of needing a server farm, then the session handling can make the leap without trouble.
Cheers,
BDKR
That's funny, I use PHP sessions due to my feelings that if my site ever grows to the point of needing a server farm I can pay someone else to make sure the session handling makes the leap since the site will be making $ at that point...roflBDKR wrote: Anyway, seeing as how Volka inserted $30.00 worth of fact there about sessions, I won't go on. Besides, I don't use PHP's session handling and prefer to store session data in a db with my own code. Much of this is a result of my feelings that if whatever site I create grows to a point of needing a server farm, then the session handling can make the leap without trouble.
Yeah, and when they foul it up, how many dollars will you loose?Elmseeker wrote: That's funny, I use PHP sessions due to my feelings that if my site ever grows to the point of needing a server farm I can pay someone else to make sure the session handling makes the leap since the site will be making $ at that point...rofl
Doh!
Cheers,
BDKR