Jump to content

Manually checking if user is logged in


VeggieSwan

Recommended Posts

I would like to manually check if the user is logged in. I would not like to make use of init.php or any other IPS made solutions. This is simply because of performance reasons. After debugging I noticed that processing init.php to check if the user is logged on is roughly 0.02s (2ms), focus on my development project is set on performance.

I dove into IPS/system/Session/Front.php to see how IPS checks if the user is logged on and I tried to re-create something like that. Right now I am checking if the user is logged on like this. I  would like to know if this is safe enough and/or if I should know about important things that init.php does that my bit of code does not. Thank you in advance.

if (isset($_COOKIE['ips4_member_id']) && is_numeric($_COOKIE['ips4_member_id']) && $_COOKIE['ips4_member_id'] > 0) {
			
	$MemberID = intval($_COOKIE['ips4_member_id']);
			
		if (isset($_COOKIE['ips4_IPSSessionFront'])) {
			
		$SessionID = $_COOKIE['ips4_IPSSessionFront'];
			
		$Session = MySQL::Get("SELECT * FROM ipbcore_sessions INNER JOIN ipbcore_members ON ipbcore_members.member_id = ipbcore_sessions.member_id WHERE id = :id",Array("id" => $SessionID));

		if (isset($Session['member_id']) && $Session['member_id'] > 0) {

			// This user is logged on.

		}

				
	}
			
}

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...