makka Posted May 8, 2007 Share Posted May 8, 2007 hay i need to make a page that i can included that will to check if there is a session set but how can i do it what about setting a cookie with the session id to resume the session but if the ip is different it will fail the cookie will expire after 12 hours also i would like it hashed or some sort of string encryption that i can just undo to read i got up to here then didn't know were witch path to take from here :S function checkcookies() { include('config.php'); if (isset($_COOKIE["game"])) { } } also i would like to know how to make a email verification system so when you make a new account you will need to have a working email and then you would click on the link and the account would become useable also is this a way of checking if the email is actual a email if (! is_email($email1)) { $errors++; $errorlist .= "Email isn't valid.<br />"; } Quote Link to comment https://forums.phpfreaks.com/topic/50542-sessions-with-cookies/ Share on other sites More sharing options...
per1os Posted May 8, 2007 Share Posted May 8, 2007 Sessions are set as cookies by default. You can store the sessionid in a cookie to restore it later if you choose. As for the IP check something like this might work <?php session_start(); function checkCookies() { if (isset($_COOKIE["game"])) { session_id($_COOKIE["game"]); if ($_SESSION['IP'] != $_SERVER['REMOTE_ADDR']) session_destroy(); // start a new session here. } } as for the is_email check, as long as is_email is a defined function there is no problems there. Quote Link to comment https://forums.phpfreaks.com/topic/50542-sessions-with-cookies/#findComment-248347 Share on other sites More sharing options...
makka Posted May 8, 2007 Author Share Posted May 8, 2007 cool there is only a few things i wish to ask now apart from my other question [code=php:0] <?php session_start(); function checkCookies() { if (isset($_COOKIE["game"])) { session_id($_COOKIE["game"]); if ($_SESSION['IP'] != $_SERVER['REMOTE_ADDR']) session_destroy(); // start a new session here. } } [/code] 1 is how can i get it to set the session cookie to that name i mean it ain't that by default and what would i do for the sesion ip to set it in the first place? Quote Link to comment https://forums.phpfreaks.com/topic/50542-sessions-with-cookies/#findComment-248355 Share on other sites More sharing options...
per1os Posted May 8, 2007 Share Posted May 8, 2007 <?php session_start(); function checkCookies() { if (isset($_COOKIE["game"])) { session_id($_COOKIE["game"]); if ($_SESSION['IP'] != $_SERVER['REMOTE_ADDR']) session_destroy(); // not sure if a new session_start() is needed here probably review www.php.net/session_destroy $_SESSION['IP'] = $_SERVER['REMOTE_ADDR']; setcookie('game', session_id(), time()+3600); } } Quote Link to comment https://forums.phpfreaks.com/topic/50542-sessions-with-cookies/#findComment-248362 Share on other sites More sharing options...
makka Posted May 8, 2007 Author Share Posted May 8, 2007 thank you now only thing i need is the email Quote Link to comment https://forums.phpfreaks.com/topic/50542-sessions-with-cookies/#findComment-248367 Share on other sites More sharing options...
per1os Posted May 8, 2007 Share Posted May 8, 2007 www.php.net/ereg www.php.net/eregi Check the user comments, a ton of people have already created email checks using regular expressions. Quote Link to comment https://forums.phpfreaks.com/topic/50542-sessions-with-cookies/#findComment-248368 Share on other sites More sharing options...
makka Posted May 8, 2007 Author Share Posted May 8, 2007 ill see if i can work it out :S also just to make my life more easy if i include my cookie page to my function page then just include that one into my pages would that work? Quote Link to comment https://forums.phpfreaks.com/topic/50542-sessions-with-cookies/#findComment-248375 Share on other sites More sharing options...
makka Posted May 8, 2007 Author Share Posted May 8, 2007 ohh one more thing how would i continue with that session now Quote Link to comment https://forums.phpfreaks.com/topic/50542-sessions-with-cookies/#findComment-248403 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.