Jump to content

Recommended Posts

OK so I created my own OTP auth system, and It work's 100% but this is what I need help with;

 

When you go to my site, it will load the auth system. You click on get auth code, it will then either SMS the code to you or send via email depending on your preference. Then you enter your email and your code you just got.

 

Now my problem is when you enter both, it doesn't direct you to the right part of the site, it keep's loading the auth system.

 

checkauth.php

if(isSet($cookie_name))
{
// Check if the cookie exists
if(isSet($_COOKIE[$cookie_name]))
{
parse_str($_COOKIE[$cookie_name]);

// Make a verification

if(($usr == $config_username) && ($hash == md5($config_password)))
	{
	// Register the session
	$_SESSION['Site-Key'] = $config_username;
	}
}
}

 

dologin.php

if(empty($_POST)) exit;

include 'config.php';

// declare post fields

$post_username = trim($_POST['username']);
$post_password = trim($_POST['authcode']);

$post_autologin = $_POST['autologin'];

if(($post_username == $config_username) && ($post_password == $config_password))
{
$_SESSION['Site-Key'] = $config_username;

// Autologin Requested?

if($post_autologin == 1)
{
$password_hash = md5($config_password); // will result in a 32 characters hash

setcookie ($cookie_name, 'usr='.$config_username.'&hash='.$password_hash, time() + $cookie_time);
}

exit('OK');
}
else
{
echo '<div id="error_notification">The submitted login info is incorrect.</div>';
}

 

doauth.php

if(isSet($_COOKIE['Site-Key']))
{
header("Location: http://mysite.com/forum");
}
else
{
header("Location: http://auth.mysite.com");
exit;
}

 

 

Any help would be greatly appreciated, everything work's but the Cookies, and redirect from cookie auth

Link to comment
https://forums.phpfreaks.com/topic/239181-one-time-code-cookie-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.