rev Posted September 2, 2011 Share Posted September 2, 2011 I have a cookie This cookie stores a value that i use to set the language on my website (not whmcs). It can be en (english) and de (german). I want to use this cookie to set language also on whmcs. As far as i know whmcs uses session for languages. The session should be $_SESSION["Language"] and can assume English and German values. How can i mix them? I tried with something like: if ($cookie = "en") { $cookie = "English"; } if ($cookie = "de") { $cookie = "German"; } // now values are equal $_SESSION["Language"] = $cookie; But it doesn't work and i think because there's a problem with session_start() since with the above code i'm in header.tpl (included). I tried also with session_destroy() with no success. Any idea? 0 Quote Link to comment Share on other sites More sharing options...
thehost5968 Posted September 2, 2011 Share Posted September 2, 2011 (edited) Where are you trying to use this code as if it is within a .tpl file the code it's self will not work and if it is PHP then the this may do it: if ($cookie == "en") { $cookie = "English"; } elseif ($cookie == "de") { $cookie .= "German"; } // now values are equal $_SESSION["Language"] = $cookie; OR unset ($_SESSION["Language"]); if (!isset ($_SESSION["Language"]) { if ($cookie = "en") { $_SESSION["Language"] = "English"; } elseif ($cookie = "de") { $_SESSION["Language"] = "German"; } } else { echo 'session is still set so this is not working! '; } Edited September 2, 2011 by thehost5968 0 Quote Link to comment Share on other sites More sharing options...
thehost5968 Posted September 2, 2011 Share Posted September 2, 2011 (edited) actually the $cookie should be $_COOKIE["name value"] = "set variable"; and find this out try: echo '<pre>'; print_r($_COOKIE); echo '</pre>'; Edited September 2, 2011 by thehost5968 0 Quote Link to comment Share on other sites More sharing options...
rev Posted September 2, 2011 Author Share Posted September 2, 2011 The code i posted was on the fly just for the post. I'm not using that code. Anyway back on topic now i understand why it's not working. On example.com i setcookie("language","en",time()+60 * 60 * 24 * 180,".example.com"); then on whmcs.example.com (i've whmcs on subdomain) i $cookie = $HTTP_COOKIE_VARS["language"]; echo $cookie; And the result of the echo is empty Why can't i pass cookies to whmcs? p.s. yes, of course, as i already said, i have this script included in the header 0 Quote Link to comment Share on other sites More sharing options...
thehost5968 Posted September 2, 2011 Share Posted September 2, 2011 try in header:echo '<pre>'; print_r($GLOBALS); echo '</pre>'; and you will see all the setting. 0 Quote Link to comment Share on other sites More sharing options...
rev Posted September 2, 2011 Author Share Posted September 2, 2011 In [HTTP_COOKIE_VARS] => Array i can see many cookies (some from vBulletin and LiveHelp) but not the one i need what's wrong in my setcookie? Atm i use setcookie ("language","en",time()+60 * 60 * 24 * 180,"/"); 0 Quote Link to comment Share on other sites More sharing options...
thehost5968 Posted September 2, 2011 Share Posted September 2, 2011 Hold on within WHMCS the language it held and stored within variable's and not session's or cookie's. you will find the one needed by using {debug} within any .tpl file. 0 Quote Link to comment Share on other sites More sharing options...
thehost5968 Posted September 2, 2011 Share Posted September 2, 2011 (edited) got it path. Edited September 2, 2011 by thehost5968 0 Quote Link to comment Share on other sites More sharing options...
rev Posted September 2, 2011 Author Share Posted September 2, 2011 Wait wait i got nothing. I know that cookie is "null" i mean there isn't my cookie but now what should i do to get it? 0 Quote Link to comment Share on other sites More sharing options...
rev Posted September 2, 2011 Author Share Posted September 2, 2011 Oooook i tried for a long time but there's nothing to do. I can find no way to pass the cookie to whmcs. I thing that i'll submit a ticket about it. 0 Quote Link to comment Share on other sites More sharing options...
thehost5968 Posted September 2, 2011 Share Posted September 2, 2011 are you able to echo the cookie from the other site within WHMCS? If so then you will just need to pass the cookie info to {$language} and if you also get a cookie on whmcs so then you will also be able to use it going back to the other site. 0 Quote Link to comment Share on other sites More sharing options...
rev Posted September 2, 2011 Author Share Posted September 2, 2011 No i can't echo the cookie this is the problem 0 Quote Link to comment Share on other sites More sharing options...
thehost5968 Posted September 3, 2011 Share Posted September 3, 2011 how have you got the 2 sites setup are we talking out home page and clinet/ support/billing = whmcs? and can you echo it on the main site? 0 Quote Link to comment Share on other sites More sharing options...
rev Posted September 3, 2011 Author Share Posted September 3, 2011 I think that i don't understand what you said. Well i've example.com (main site) and whmcs.example.com (whmcs) and yes, i can echo the cookie on example.com but not on whmcs.example.com. 0 Quote Link to comment Share on other sites More sharing options...
thehost5968 Posted September 3, 2011 Share Posted September 3, 2011 are they both within the same account (i.e. cPanel account)? You have not set-up the cookie for a domain only? try taking out the 4 part the path? Also could you when setting the cookie not also send a hidden post to whmcs to also store it? 0 Quote Link to comment Share on other sites More sharing options...
rev Posted September 3, 2011 Author Share Posted September 3, 2011 (edited) On example.com i setcookie("language","en",time()+60 * 60 * 24 * 180,".example.com"); Damn it Little oversight it's setcookie("language","en",time()+60 * 60 * 24 * 180,"/",".example.com");. That's why it wasn't working. I must stop going by memory when i write php. Edited September 3, 2011 by rev 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.