session - redirect back to previous page php -


i trying redirect user page he/she after successful login not working right me.

the problem instead of redirecting previous page redirects account.php..

edit: have session started on page , including file.

the main page... index.php

<?php   include_once("models/config.php"); $_session['page'] = 'index.php'; ?> 

and here login php..

 if(isset($_session["page"]) && is_object($_session["page"])) //check if session exists                {  //redirect user previous page  header("location:".$_session['page']);                 }  else{header("location:account.php");die();} 

you need add exit or else continue process rest of script.

if(!empty($_session["page"])) //check if session exists {    //redirect user previous page    header("location:".$_session['page']);    exit; } else{header("location:account.php");exit;} 

as christopher morrissey stated, $_session['page'] won't object. make sure variable exists , has value using !empty.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -