Josh Posted March 28, 2017 Share Posted March 28, 2017 I'm trying to remeber the user's language with a cookie in PHP: <?php //Set language and remember with cookie $lang = $_GET['lang']; if ($lang==null) { $lang = $_COOKIE["lang"]; if ($lang==null) $lang = "lua"; } setcookie("lang",$lang,time()+30*24*60*60); ?><!DOCTYPE html> <html> <head> <title>Leadwerks Game Engine Documentation</title> Here is a URL with the language specified to CPP: http://www.leadwerks.com/learn.php?page=API-Reference_Object_Entity_SetPosition〈=cpp'>http://www.leadwerks.com/learn.php?page=API-Reference_Object_Entity_SetPosition〈=cpp This URL does not specify any language, and will default to LUA: http://www.leadwerks.com/learn.php?page=API-Reference_Object_Entity_SetPosition However, if you click the first link then the second link, a cookie should remember your language selection and display CPP the second time. Why is this not working? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 28, 2017 Author Share Posted March 28, 2017 According to FF page info, the cookie exists and is set to 'cpp' yet it doesn't seem to get loaded. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
martyj Posted March 28, 2017 Share Posted March 28, 2017 I'm not getting a request to set a cookie when I visit that page. When a server wants to add a cookie to a users browser, the server will send a "Set-Cookie" header. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie A simple solution and one that I prefer is to use $_SESSION instead of cookie. That way the data is stored on the server instead of on the users browsers making it more secure. Make sure to call session_start() when working with $_SESSION. Quote Link to comment Share on other sites More sharing options...
Josh Posted March 28, 2017 Author Share Posted March 28, 2017 I got it working! You have to click on the Lua / CPP links in the documentation page, but it works. So if you just select C++ once, it will stay that way next time you open a page. One step closer. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
martyj Posted March 29, 2017 Share Posted March 29, 2017 So I take it you don't dig my angular app? No worries. I didn't put that much time into it lol. Quote Link to comment Share on other sites More sharing options...
Josh Posted March 29, 2017 Author Share Posted March 29, 2017 So I take it you don't dig my angular app? No worries. I didn't put that much time into it lol. What are you referring to? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Ma-Shell Posted March 29, 2017 Share Posted March 29, 2017 What are you referring to? http://www.leadwerks.com/werkspace/topic/15851-documentation-xml-raw-data/#entry105733 Btw. I copied the PHP code you posted above and tried it locally and it worked... Quote Link to comment Share on other sites More sharing options...
Josh Posted March 29, 2017 Author Share Posted March 29, 2017 http://www.leadwerks.com/werkspace/topic/15851-documentation-xml-raw-data/#entry105733 Btw. I copied the PHP code you posted above and tried it locally and it worked... How does asking a question about cookies equal I dislike something you made? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
martyj Posted March 29, 2017 Share Posted March 29, 2017 How does asking a question about cookies equal I dislike something you made? Well you're re-writing the documentation so I just assumed, why re-invent the wheel twice. Quote Link to comment Share on other sites More sharing options...
Josh Posted March 29, 2017 Author Share Posted March 29, 2017 I posted the XML links for people to experiment with if they wanted to. I was not asking you guys to design the official docs. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. 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.
Note: Your post will require moderator approval before it will be visible.