spikereloaded Posted December 14, 2013 Share Posted December 14, 2013 (edited) Hey, has anyone made a mod (rather more like showing a few pieces of code) regarding allowing users to follow links after logging in. For example, we use email notifications and i figured it would be better if rather than just having to login then navigate to the right page, instead you login and are redirected to the mailbox page that was linked to in the email. I can post up the mod if anyone is actually interested in it, however i think it would only apply to games that have links coming in from the outside (such as email notifications, facebook pages etc) Also i couldn't think of what to call it so couldn't check if it was already on the forums! EDITED: here's how i've done it. seems to work well so, in globals.php you want to find: if($_SESSION['loggedin']==0) { header("Location: login.php");exit; } and enter just above it : if($_SESSION['loggedin']==0 && $_SERVER['REQUEST_URI'] != 'login.php'){$_SESSION['navto'] = $_SERVER['REQUEST_URI'];} That will assign the original requested url to the variable $_SESSION['navto'] and the first bit of code you had to find will redirect the (unlogged in) user back to the login page. Now on authenticate.php you want to find : header("Location: loggedin.php"); and change it to look as below: if($_SESSION['navto']) { header("Location: {$_SESSION['navto']}"); unset($_SESSION['navto']); } else { header("Location: loggedin.php"); } This will check to see if there is a variable set called $_SESSION['navto'] and if there is it will redirect to the address that was previously assigned to the $_SESSION['navto'] variable by globals.php. Then it will unset the variable to avoid any confusion later. if there is no set $_SESSION['navto'] variable, it will direct to loggedin.php as normal. I think it definitely makes incoming links a lot more useful and cuts down on players not being able to find a link and giving up (not that that should be happening anyway) or just forgetting to navigate to the page they originally logged in to look at. Not to mention it's a bit more professional to link directly to what you want them to look at! Edited December 14, 2013 by spikereloaded Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted December 14, 2013 Share Posted December 14, 2013 something like if (isset ($_GET["navTo"])) { header("Location: " . $_GET["navTo"] . ".php); } Quote Link to comment Share on other sites More sharing options...
spikereloaded Posted December 14, 2013 Author Share Posted December 14, 2013 similar, but the version i've done doesn't use GET, it uses a session variable instead. It lets you link to your pages just like a normal page link, eg endoftimez.com/mailbox.php. Then if you click it and your not logged in, when you are redirected to the login page, the requested page (in this case mailbox.php) is assigned to the $_SESSION['navTo'] variable. then on logging in, if the session variable (navTo) is set it will redirect you to that page. It's pretty straight forward but it's useful and i couldn't for the life of me think of what to call it when i had a look round to see if anyone had previously done it on here. Does it have a name? Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted December 14, 2013 Share Posted December 14, 2013 I would be pretty interested in seeing how you went about it Quote Link to comment Share on other sites More sharing options...
spikereloaded Posted December 14, 2013 Author Share Posted December 14, 2013 edited original post to include my code! 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.