Solarpitch Posted December 26, 2006 Share Posted December 26, 2006 Hey Guys, Just wondering if I can use a session variable to remember what page the user was at last. ie. If user tries to login, it will bring them to process_login.php. If the login failed, the user selects "go back" and it will load the page that the user tired to login at.Cheers. Link to comment https://forums.phpfreaks.com/topic/31877-using-a-session-variable-to-remember-a-page/ Share on other sites More sharing options...
Orio Posted December 26, 2006 Share Posted December 26, 2006 Yes you can, you just need to do something like this on the top of every page (after session_start()).[code]<?php$_SESSION['last_page'] = (!isset($_SESSION['curr_page'])) ? "index.php" : $_SESSION['curr_page'];$_SESSION['curr_page'] = $_SERVER['PHP_SELF'];?>[/code]Then you can use the header() function to redirect using $_SESSION['last_page'].Orio. Link to comment https://forums.phpfreaks.com/topic/31877-using-a-session-variable-to-remember-a-page/#findComment-147928 Share on other sites More sharing options...
Solarpitch Posted December 26, 2006 Author Share Posted December 26, 2006 Ahh! excellent, thanks! :) Link to comment https://forums.phpfreaks.com/topic/31877-using-a-session-variable-to-remember-a-page/#findComment-147929 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.