| Author | Message | 
                                                                                                    
                                                        | John van der Boom
                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Tuesday 22 July 2003 1:33:37 am 
                                                                
                                                                  Hello, Sorry, that I'm cross posting, but I don't know where this topic belongs to. I'm running a script with eZp that needs to read some value from a cookie like this: $var_A = $_COOKIE['var_A']; This script works perfect standalone., but when I run it inside eZp the value of var_A is empty. 
Is there a way to solve this problem?Thank you in advance
 | 
                                                
                                                                                                                                                        
                                                        | Bård Farstad
                                                                                                                             | Tuesday 22 July 2003 1:38:01 am 
                                                                 You should use the eZHTTPTool class to fetch variables. I would not recommend using cookies for variable storage, use session instead. 
The global variables are not available in Exponential modules. You need to fetch them from the global array directly $GLOBALS["_COOKIE"]['var_A'];
 --bård Documentation: http://ez.no/doc
 | 
                                                                                                    
                                                        | John van der Boom
                                                                                                                             | Tuesday 22 July 2003 9:38:44 am 
                                                                 Thank your for your reply Bard. 
But I don't I understand what your're trying to tell me.I have cookie with this entry:
 
member_id some_valueetc...
 Reading at your reply I thought that I need to fetch the member_id value like this: $member_id = $GLOBALS["_COOKIE"]['member_id']; 
But this didn't work. So I went on to read SDK and there was some info about fetching variables with eZHTTPToolSo I tried this:
 
$http =& eZHTTPTool::instance();$member_id = $GLOBALS["_COOKIE"]['member_id'];
 
without any luck. Can you explain me further how to do this?Thank you very much.
 | 
                                                                                                    
                                                        | John van der Boom
                                                                                                                             | Tuesday 22 July 2003 10:22:35 pm 
                                                                 In my exploring to see how the GLOBAL variables work, I tried this: 
$var = $GLOBALS["eZINIOverrideDirList"];echo (" $var" ) ;
 
Just an example I took from the ezini.php file. But then again the echo isn't showing me anything.
 What's the problem do you think? | 
                                                                                                    
                                                        | Jan Borsodi
                                                                                                                             | Wednesday 23 July 2003 12:42:22 am 
                                                                 The first question is where is the script run, in the index.php or trough a module or something else? You could try this. 
global $_COOKIE;$var_A = $_COOKIE['var_A'];
 
you can also see what the $_COOKIE variable contains withprint( "<pre>" );
 var_dump( $_COOKIE );
 print( "</pre>" );
 
Maybe this documentation have some clueshttp://www.php.net/manual/en/function.setcookie.php
 -- Amos
 
 Documentation: http://ez.no/ez_publish/documentation
 FAQ: http://ez.no/ez_publish/documentation/faq
 | 
                                                                                                    
                                                        | John van der Boom
                                                                                                                             | Wednesday 23 July 2003 3:58:44 am 
                                                                 I think this problem has to do with the way I'm calling the secript. Why do I think so, cause standalone the script works perfectly and with the: 
global $_COOKIE;print( "<pre>" );
 var_dump( $_COOKIE );
 print( "</pre>" );
 I see all the variables in the cookie. The script is being called in eZp like this: {"http://localhost/scripts/myscript.php"|insert} 
So the script is running trough the content module, I think....Seems like this is giving me the cookie problem. Everything works perfect except the cookie calling.
 In a previous reply Bard wrote this: "The global variables are not available in Exponential modules."
 
Is this the problem? If yes, is there another way to solve this? Because I don't know how to run the script in the index.php and still outputing it in the templates.
 Thank your for your time and patient. | 
                                                                                                    
                                                        | John van der Boom
                                                                                                                             | Friday 25 July 2003 10:22:22 am 
                                                                 
Is it possible to make a module that make it possibel to set and read cookies? Because I think I'll gonna try and program this as a module (if this is the correct term)
 | 
                                                                                                    
                                                        | liu spider
                                                                                                                             | Saturday 26 July 2003 3:35:15 am 
                                                                 
add global $_COOKIE;
 to the top of your scripts, and they should work well
 http://liucougar.scim-im.orgSCIM Input Method Platform
 http://scim.sf.net
 SJSD Online Editor
 http://sf.net/projects/sjsd
 | 
                                                                                                    
                                                        | Jan Borsodi
                                                                                                                             | Saturday 26 July 2003 4:17:36 am 
                                                                 
Actually there's no need for aglobal $_COOKIE;
 I read trough the PHP documentation and some PHP variables are always available globally.
 Secondly Exponential does not touch cookies directly, the session system will set a cookie but all of this code is handled by PHP. So if the _COOKIE variable is empty there must be a configuration problem or the setcookie code is not run. 
From the setcookie documentation:setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.
 Do you get some errors on your page, like HTTP headers already sent? (Debug must be enabled too see this) -- Amos
 
 Documentation: http://ez.no/ez_publish/documentation
 FAQ: http://ez.no/ez_publish/documentation/faq
 | 
                                                                                                    
                                                        | liu spider
                                                                                                                             | Saturday 26 July 2003 7:27:00 am 
                                                                 If that's the case, a simple solution is to enable the output buffer. This can be set in system global php.ini, or in apache config file. 
Below is cutted from php.ini; Output buffering allows you to send header lines (including cookies) even
 ; after you send body content, at the price of slowing PHP's output layer a
 ; bit. You can enable output buffering during runtime by calling the output
 ; buffering functions. You can also enable output buffering for all files by
 ; setting this directive to On. If you wish to limit the size of the buffer
 ; to a certain size - you can use a maximum number of bytes instead of 'On', as
 ; a value for this directive (e.g., output_buffering=4096).
 output_buffering = Off
 http://liucougar.scim-im.orgSCIM Input Method Platform
 http://scim.sf.net
 SJSD Online Editor
 http://sf.net/projects/sjsd
 | 
                                                                                                    
                                                        | John van der Boom
                                                                                                                             | Monday 28 July 2003 3:24:52 am 
                                                                 I'm not having problem setting the cookie but getting the values from the cookie. The cookies are already set with setcookie(). Indeed $_cookies should always be available in the script. That's why I'm not getting why it won't work if I include the script with the operator {"http://localhost/scripts/myscript.php|insert"} Since I can't change the php.ini settings (btw the output_buffering of mine is set to "no_value"). I have to try something else. I'm echoing the cookie vars in index.php : 
$myvar = $_cookie['var_A'];echo $myvar;
 
This is working fine.Now I want this variable ($myvar) to be known in template is this possible?
 
How can I accomplish this?Thanks so far for your help
 |