TFT2012 Posted February 13, 2013 Share Posted February 13, 2013 Hi, I have question about the PHP session. First, I have the site directory like this: -- root ---- classes -------- auth.php -------- curldata.php ---- includes -------- longin.php ---- index.php ---- dashboard.php ---- readapc.php The index.php has the login form: <form action="includes/login.php" method="post"> If login is successful, the login.php will do: require_once ("../classes/auth.php"); if ( success) { $_SESSION["logged"] = true; $_SESSION["user"] = array information // The user information array is returned from "auth.php". header("Location: ../dashboard.php"); } else header("Location: ../index.php"); In dashboard.php, it will display the $_SESSION['user'] data correctly. If clicking the link to readapc.php inside dashboard.php, the $_SESSION['user'] is good as well. The problem happened when I do the following code inside "readapc.php": (It is okay if I don't do this) require_once ("classes/curldata.php"); $result = data retrieved from curldata.php; $_SESSION['data'] = $result; If I do the things above, when I click the readapc.php, the session data is gone, readapc.php does NOT show $_SESSION['user'] data no more. (I am in readapc.php page now). But the $_SESSION['data'] is displayed well. Then, if I click dashboard.php link, it will jump to login page (index.php) because I setup if (!isset($_SESSION['logged'])) header("Location: index.php") on all index.php, dashboard.php, and readapc.php. Could anyone give me a hand on this problem? Thanks! Link to comment https://forums.phpfreaks.com/topic/274426-php-session-question/ Share on other sites More sharing options...
scootstah Posted February 13, 2013 Share Posted February 13, 2013 Are you using session_start anywhere? Link to comment https://forums.phpfreaks.com/topic/274426-php-session-question/#findComment-1412146 Share on other sites More sharing options...
TFT2012 Posted February 13, 2013 Author Share Posted February 13, 2013 Are you using session_start anywhere? Yeah, I applied session_start() in all index.php, dashboard.php, readapc.php, and includes/login.php Link to comment https://forums.phpfreaks.com/topic/274426-php-session-question/#findComment-1412165 Share on other sites More sharing options...
scootstah Posted February 13, 2013 Share Posted February 13, 2013 So what is in curldata.php? Link to comment https://forums.phpfreaks.com/topic/274426-php-session-question/#findComment-1412168 Share on other sites More sharing options...
TFT2012 Posted February 13, 2013 Author Share Posted February 13, 2013 So what is in curldata.php? This file contains the class CurlData{}. parseapc.php calls the data service from it in order to retrieve the necessary data. So I don't put session_start() inside. Link to comment https://forums.phpfreaks.com/topic/274426-php-session-question/#findComment-1412172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.