guntersammet Posted January 9, 2004 Share Posted January 9, 2004 Hello all: This might be a developers question but maybe other users encounter the same problem, so I place it here. I have almost the newest CVS version (application_top.php is version 1.82) and have SESSION_FORCE_COOKIE_USE set to 'True'. The shop isn't live yet, so no real problem. I noticed that every time I called the url, I get an error regarding includes. The language isn't set. Refreshing the browser and everything works like a charm. Tracking it down, I ended up finding the source in this piece of code: // start the session if (SESSION_FORCE_COOKIE_USE == 'True') { tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain); if (isset($_COOKIE['cookie_test'])) { $osC_Session->start(); } Reading through the php docs, I think what most likely happens is that a cookie is set but it's not available till the next reload. Here a snipet from php docs (http://www.php.net/manual/en/function.setcookie.php): Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE or $HTTP_COOKIE_VARS arrays. Note, autoglobals such as $_COOKIE became available in PHP 4.1.0. $HTTP_COOKIE_VARS has existed since PHP 3. Cookie values also exist in $_REQUEST. If this is true, above code in application_top.php can't work because the $_COOKIE['cookie_test'] wouldn't be set and the session is not started. I will turn of the force cookie for now and do some more testing. One thing I don't understand completely is, what happens to spiders if they access the site with force cookies set to true. They would get the error every time they try to access the site because a session wouldn't be started unless they accept the cookie (don't know enough about spiders, so I am not sure if they allow cookies and if they would automatically try to reconnect to the site.). And if a session isn't started, the language file can't be taken from the session variable. Have to do some more code thinking here. The changed code might be always a problem with spiders since there is no session start. If there is no session start, including the language file through calling the session language variable can't work. Hope this makes sense to some of you. Would appreciate if some people could look into this to make sure the new versions won't have problems with spiders. Cheers, Gunter Link to comment Share on other sites More sharing options...
guntersammet Posted January 9, 2004 Author Share Posted January 9, 2004 I were just playing around with the spider simulation and added my browser to the spiders.txt. It seems like my asumption has been right and the spider won't get a page served since it doesn't get a language assigned. One solutions would be, to change the following: function set($variable, &$value) { if ($this->is_started == true) { $_SESSION[$variable] = $value; return true; } return false; } to something like that: function set($variable, &$value) { $_SESSION[$variable] = $value; return true; } I am not a session expert, so I don't know if this would brake anything. Any input would be appreciated. BTW, I don't understand why the variable $value is passed by reference (&$value). Could somebody please tell me. Thanks! Gunter Link to comment Share on other sites More sharing options...
Guest Posted January 9, 2004 Share Posted January 9, 2004 BTW, I don't understand why the variable $value is passed by reference (&$value). Hello Gunter, in php if the value of a variable is changed inside a function, the value outside is not effectet. the & exports the new value without to set a global variable or a return at the end of the function. cheers andi Link to comment Share on other sites More sharing options...
guntersammet Posted January 9, 2004 Author Share Posted January 9, 2004 BTW, I don't understand why the variable $value is passed by reference (&$value). Hello Gunter, in php if the value of a variable is changed inside a function, the value outside is not effectet. the & exports the new value without to set a global variable or a return at the end of the function. cheers andi Thanks Andi. I have just been wondering why it's passed by reference since the variable isn't changed in there. Is this for future use or maybe to reflect the correct value if the variable is changed from somewhere else while the session set function is called. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.