Jump to content
MakeWebGames

Following links


Recommended Posts

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 by spikereloaded
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...