php - Sessions are not working after redirection -
here code setting sessions in user-authentication.php
:
session_start(); $_session['admin_name'] = $name; $_session['sbc_admin'] = "y"; $_session['admin_email'] = $email; header("location:includes/user-auth.php");
and here's code check whether sessions set or in user-auth.php
:
session_start(); if (isset($_session["sbc_admin"])) { $admin = $_session["sbc_admin"]; $name = $_session["admin_name"]; $email = $_session["admin_email"]; } else { header("location:../index.php"); }
after redirection, session variables lost. have tried few tricks it's still not working.
take session_start();
, place @ top of of code. want 1 of, if not, first method run.
i tend create file called lib.php
called header.php document. lib file contains object creation, functions, etc. first bit of code on page is:
<?php session_start(); //the rest of code here
Comments
Post a Comment