web_master Posted September 29, 2007 Share Posted September 29, 2007 Hi, Ive got a cookie for identify the registered user. But - I must to have the session number to. How can I add the session number if I had a cookie: <?php //Create array of supported languages $languages = array('en', 'hu', 'sr'); //Check the $_GET value if exists if (isset($_GET['language']) && in_array($_GET['language'], $languages)) { $language = $_GET['language']; $_SESSION['language'] = $language; setcookie('language', $language, time()+60*60*24*365); //Check the COOKIE value if $language not set } elseif (isset($_COOKIE['language']) && in_array($_COOKIE['language'], $languages)) { $language = $_COOKIE['language']; $_SESSION['language'] = $language; //Check the SESSION value if $language not set (in case cookies disabled) } elseif (isset($_SESSION['language']) && in_array($_SESSION['language'], $languages)) { $language = $_SESSION['lang']; //Language still not set, use default } else { $language = $languages[3]; $_SESSION['language'] = $language; setcookie('language', $language, time()+60*60*24*365); } ?> Thanx in advanced Quote Link to comment https://forums.phpfreaks.com/topic/71141-solved-cookie-session/ Share on other sites More sharing options...
wildteen88 Posted September 29, 2007 Share Posted September 29, 2007 use session_id() to grab the users unique sessions id. Quote Link to comment https://forums.phpfreaks.com/topic/71141-solved-cookie-session/#findComment-357792 Share on other sites More sharing options...
web_master Posted September 29, 2007 Author Share Posted September 29, 2007 Thanx wildteen88, its work - Ill never use it before.... Quote Link to comment https://forums.phpfreaks.com/topic/71141-solved-cookie-session/#findComment-357795 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.