Re: [PHP] Session variable under PHP 4.0.6
Kirk Johnson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] If register_globals is Off in php.ini, then do the following: - do not use session_register(), etc. - use $HTTP_SESSION_VARS for all accesses. I have code similar to Henry's running fine on both 4.0.5 and 4.2.3 servers with register_globals set to On. His code _should_ work. I think there's some other setting in php.ini that's causing an issue here. Henry, could you do a phpinfo() and show us the results? Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session variable under PHP 4.0.6
Hi All, I'm having a problem with session variables under PHP 4.0.6 on a secure server. I ran phpinfo and have attached the resulting page after the main body of this message. My test code looks like this Filename: index.php Page Start -- ?php session_start(); $HTTP_SESSION_VARS['variable']=the variables value; ? a href=index2.phpclick here/a to go to the next page Page End -- Next file Filename: index2.php Page Start -- ?php session_start(); print_r($HTTP_SESSION_VARS); echo --gt;.$HTTP_SESSION_VARS['variable'].lt;--; ? Page End -- Suffice to say it doesn't work. The first page displays click here to go to the next page as expected. However clicking on the link takes you to index2.php and the following is displayed: Array ( ) Namely that the session variable called variable is not set in the session. I have run the exact same code on a machine running PHP 4.2.3 (non secure servers) and it works perfectly! And outputs: Array ( [variable] = the variables value ) --the variables value-- Exactly as required!! I hope that you can help, since I am getting frustrated after 4 days trying to fix this problem. Henry -- Sorry about the formating but this is what I got from phpinfo from the machine PHP Version 4.0.6 Build Date Oct 7 2001 Configure Command './configure' '--with-mysql' '--with-apxs=/usr/sbin/apxs' '--enable-track-vars' '--with-config-file-path=/etc' '--enable-magic-quotes' '--enable-apc=shared' '--with-xml' '--enable-trans-sid' '--with-pgsql' '--with-zlib' Server API Apache Virtual Directory Support disabled Configuration File (php.ini) Path /etc/php.ini ZEND_DEBUG disabled Thread Safety disabled This program makes use of the Zend scripting language engine: Zend Engine v1.0.6, Copyright (c) 1998-2001 Zend Technologies with Zend Optimizer v1.1.0, Copyright (c) 1998-2000, by Zend Technologies PHP 4.0 Credits Configuration PHP Core Directive Local Value Master Value allow_call_time_pass_reference On On allow_url_fopen 1 1 arg_separator.input arg_separator.output asp_tags Off Off auto_append_file no value no value auto_prepend_file no value no value browscap no value no value default_charset no value no value default_mimetype text/html text/html define_syslog_variables Off Off disable_functions no value no value display_errors On On display_startup_errors Off Off doc_root no value no value enable_dl On On error_append_string no value no value error_log no value no value error_prepend_string no value no value error_reporting 2039 2039 expose_php On On extension_dir ./ ./ file_uploads 1 1 gpc_order GPC GPC highlight.bg #FF #FF highlight.comment #FF9900 #FF9900 highlight.default #CC #CC highlight.html #00 #00 highlight.keyword #006600 #006600 highlight.string #CC #CC html_errors On On ignore_user_abort Off Off implicit_flush Off Off include_path .:/usr/local/lib/php .:/usr/local/lib/php log_errors Off Off magic_quotes_gpc On On magic_quotes_runtime Off Off magic_quotes_sybase Off Off max_execution_time 30 30 open_basedir no value no value output_buffering Off Off output_handler no value no value post_max_size 8M 8M precision 14 14 register_argc_argv On On register_globals On On safe_mode Off Off safe_mode_exec_dir no value no value sendmail_from [EMAIL PROTECTED] [EMAIL PROTECTED] sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i short_open_tag On On SMTP localhost localhost sql.safe_mode Off Off track_errors Off Off upload_max_filesize 2M 2M upload_tmp_dir no value no value user_dir no value no value variables_order EGPCS EGPCS y2k_compliance Off Off xml XML Support active standard Regex Library Bundled library enabled Dynamic Library Support enabled Path to sendmail /usr/sbin/sendmail -t -i Directive Local Value Master Value assert.active 1 1 assert.bail 0 0 assert.callback no value no value assert.quiet_eval 0 0 assert.warning 1 1 safe_mode_allowed_env_vars PHP_ PHP_ safe_mode_protected_env_vars LD_LIBRARY_PATH LD_LIBRARY_PATH session.use_trans_sid 1 1 url_rewriter.tags a=href,area=href,frame=src,input=src,form=fakeentry a=href,area=href,frame=src,input=src,form=fakeentry session Session Support enabled Directive Local Value Master Value session.auto_start Off Off session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.name PHPSESSID PHPSESSID
RE: [PHP] Session variable under PHP 4.0.6
In the first file, replace this line: $HTTP_SESSION_VARS['variable']=the variables value; with these two lines: $variable = the variables value; session_register('variable'); This is because 'register_globals' is enabled in the php.ini file. Kirk -Original Message- From: Henry Grech-Cini [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 9:34 AM To: [EMAIL PROTECTED] Subject: [PHP] Session variable under PHP 4.0.6 Hi All, I'm having a problem with session variables under PHP 4.0.6 on a secure server. I ran phpinfo and have attached the resulting page after the main body of this message. My test code looks like this Filename: index.php Page Start -- ?php session_start(); $HTTP_SESSION_VARS['variable']=the variables value; ? a href=index2.phpclick here/a to go to the next page Page End -- Next file Filename: index2.php Page Start -- ?php session_start(); print_r($HTTP_SESSION_VARS); echo --gt;.$HTTP_SESSION_VARS['variable'].lt;--; ? Page End -- Suffice to say it doesn't work. The first page displays click here to go to the next page as expected. However clicking on the link takes you to index2.php and the following is displayed: Array ( ) Namely that the session variable called variable is not set in the session. I have run the exact same code on a machine running PHP 4.2.3 (non secure servers) and it works perfectly! And outputs: Array ( [variable] = the variables value ) --the variables value-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session variable under PHP 4.0.6
Thanks that works in my testing example. But why? The manual says: Caution If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister(). But in index2.php I am using $HTTP_SESSION_VARS and it works?! Need a bit of clarification since my actual app still doesn't work! Henry Kirk Johnson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In the first file, replace this line: $HTTP_SESSION_VARS['variable']=the variables value; with these two lines: $variable = the variables value; session_register('variable'); This is because 'register_globals' is enabled in the php.ini file. Kirk -Original Message- From: Henry Grech-Cini [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 9:34 AM To: [EMAIL PROTECTED] Subject: [PHP] Session variable under PHP 4.0.6 Hi All, I'm having a problem with session variables under PHP 4.0.6 on a secure server. I ran phpinfo and have attached the resulting page after the main body of this message. My test code looks like this Filename: index.php Page Start -- ?php session_start(); $HTTP_SESSION_VARS['variable']=the variables value; ? a href=index2.phpclick here/a to go to the next page Page End -- Next file Filename: index2.php Page Start -- ?php session_start(); print_r($HTTP_SESSION_VARS); echo --gt;.$HTTP_SESSION_VARS['variable'].lt;--; ? Page End -- Suffice to say it doesn't work. The first page displays click here to go to the next page as expected. However clicking on the link takes you to index2.php and the following is displayed: Array ( ) Namely that the session variable called variable is not set in the session. I have run the exact same code on a machine running PHP 4.2.3 (non secure servers) and it works perfectly! And outputs: Array ( [variable] = the variables value ) --the variables value-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Session variable under PHP 4.0.6
That Caution message is not the full story, read some more on register_globals. If register_globals is On in php.ini, then do the following: - use session_register() to create your session variables; - use the global variable to access the variable, not the $HTTP_SESSION_VARS array. Example: $myVar = 'test'; session_register('myVar'); $myVar = 'some new value'; print $myVar; Note: the value of $myVar is what is stored to the session at the end of the script. And, since it is stored after the script ends, its value is not available via $HTTP_SESSION_VARS[] until the next page. If register_globals is Off in php.ini, then do the following: - do not use session_register(), etc. - use $HTTP_SESSION_VARS for all accesses. Example: $HTTP_SESSION_VARS['myVar'] = 'test'; $HTTP_SESSION_VARS['myVar'] = 'some new value'; print $HTTP_SESSION_VARS['myVar']; Kirk -Original Message- From: Henry Grech-Cini [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 10:29 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] Session variable under PHP 4.0.6 Thanks that works in my testing example. But why? The manual says: Caution If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister(). But in index2.php I am using $HTTP_SESSION_VARS and it works?! Need a bit of clarification since my actual app still doesn't work! Henry Kirk Johnson [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In the first file, replace this line: $HTTP_SESSION_VARS['variable']=the variables value; with these two lines: $variable = the variables value; session_register('variable'); This is because 'register_globals' is enabled in the php.ini file. Kirk -Original Message- From: Henry Grech-Cini [mailto:[EMAIL PROTECTED] Sent: Monday, March 03, 2003 9:34 AM To: [EMAIL PROTECTED] Subject: [PHP] Session variable under PHP 4.0.6 Hi All, I'm having a problem with session variables under PHP 4.0.6 on a secure server. I ran phpinfo and have attached the resulting page after the main body of this message. My test code looks like this Filename: index.php Page Start -- ?php session_start(); $HTTP_SESSION_VARS['variable']=the variables value; ? a href=index2.phpclick here/a to go to the next page Page End -- Next file Filename: index2.php Page Start -- ?php session_start(); print_r($HTTP_SESSION_VARS); echo --gt;.$HTTP_SESSION_VARS['variable'].lt;--; ? Page End -- Suffice to say it doesn't work. The first page displays click here to go to the next page as expected. However clicking on the link takes you to index2.php and the following is displayed: Array ( ) Namely that the session variable called variable is not set in the session. I have run the exact same code on a machine running PHP 4.2.3 (non secure servers) and it works perfectly! And outputs: Array ( [variable] = the variables value ) --the variables value-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php