How to secure my PHP webpage from unauthorized Users -


i new in php , facing problem security. use redirect unauthorized users if not logged in.

<?php session_start();  if(!isset($_session['user_id'])) {     header('location: login.php'); } ?> 

it on every top of page when log in , click protected page redirect login page instead of original/protected page open , session variable set on login page how include session variable in protected page login page.

if when, log in, sends login page, $_session['user_id'] may not set, or aren't including session in file, check it, do:

var_dump($_session['user_id'])

on page, , temporally leave out header if var_dump returns null, means, $_session['user_id'] not set


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -