PHP Custom Authentication Approach -
i in process of building custom backend user control panel in php.
i seeking advice on how best manage authentication of users. have written own custom registration , login system (i not intend use server based authentication). plans set session variable once user authenticated , use allow/disallow access.
is correct approach or insecure, want protect against users might attempt by-pass authentication, , valid users want able restrict data, example user 4 shouldn't see users 1,2 or 3's personal data.
how easy mask/trick/cheat php session variable?
a session variable data stored on server. every sessions contains unique identifier connects cookie session ( stored data ). when don't have identifier cant request session.
the safety issue here cookie can hijacked. better security need check on ip address.
for example:
if($login === true) $session['userdata'] = array("ip" => "11.11.11.11", "userid" => "5");
should have following check:
if($_session['userdata']['ip'] == $_server['remote_host']) { /* checks , stuff. */ } else { die("session not belong you!"); }
when ip check impossible hijack session cookie ( or need in same network , stuff )