
A.White.89
Members-
Posts
22 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
A.White.89's Achievements

Newbie (1/5)
0
Reputation
-
[SOLVED] Changing Session variables between pages
A.White.89 replied to A.White.89's topic in PHP Coding Help
Oh geeze, thanks for both the solution and the tip about the messages. I really appreciate your perserverence through this discussion. -
[SOLVED] Changing Session variables between pages
A.White.89 replied to A.White.89's topic in PHP Coding Help
Are you suggesting to add that to the top of EACH page? So that it would only last 10 minutes from the load time of that page? -
[SOLVED] Changing Session variables between pages
A.White.89 replied to A.White.89's topic in PHP Coding Help
I am trying to make it logout after 10 minutes of INACTIVITY, not just 10 minutes period. That's why I change the session variable on each page AFTER I check the value of the session variable to make sure the current time is not 600 seconds more than the last loaded page. For some reason, that difference is always increasing, suggesting that the variable is NOT storing between pages. -
[SOLVED] Changing Session variables between pages
A.White.89 replied to A.White.89's topic in PHP Coding Help
<?php function secure($_SESSION) { if(!($_SESSION['userID']) || ($_SESSION['userID'] == "")) { header("Location: login.php?page=".$_SERVER['PHP_SELF']); exit(); } } function timeoutCheck($activeTime) { $maxNoActivity = 600; // Seconds of session duration of no activity $difference = time() - $activeTime; print $difference; if($difference > $maxNoActivity) { session_destroy(); header("Location: login.php?timeout=1&page=".$_SERVER['PHP_SELF']); } } ?> secure() doesn't touch $_SESSION['activeTime'] and works well to make sure a user is logged in before being able to access the page (suggesting that the $_SESSION['userID'] is being transferred fine). -
[SOLVED] Changing Session variables between pages
A.White.89 replied to A.White.89's topic in PHP Coding Help
Okay. If I make the question simple: Have you ever heard of session variables not storing between pages and/or functions? I do thank you for your answer though. It is useful. -
[SOLVED] Changing Session variables between pages
A.White.89 replied to A.White.89's topic in PHP Coding Help
Okay. Here is the code from above (the timeoutCheck function): from loginFunction.php: <?php function timeoutCheck($activeTime) { $maxNoActivity = 600; // Seconds of session duration of no activity $difference = (time() - $activeTime); //print $difference; if($difference > $maxNoActivity) { session_destroy(); header("Location: login.php?timeout=1&page=".$_SERVER['PHP_SELF']); } } ?> and here is the code that rests at the top of all my pages: <?php session_start(); require "loginFunctions.php"; secure($_SESSION); timeoutCheck($_SESSION['activeTime']); $_SESSION['activeTime']= time(); ?> If I print out on any page AFTER the timeoutCheck: <?php print (time() - $_SESSION['activeTime']); ?> I get 0 - which is good. This suggests that $_SESSION['activeTime'] is changed within the page but it is not being transferred to other pages because in timeoutCheck, the variable is no different than it is when it is instantiated - which is here (in login.php): <?php $error = loginCheck($_POST, $_GET); if(trim($error) == "") { $_SESSION['userID'] = login($_POST); $_SESSION['activeTime'] = time(); // LOOK HERE // The rest is not important ?> Hopefully this helps. Thanks. -
[SOLVED] Changing Session variables between pages
A.White.89 replied to A.White.89's topic in PHP Coding Help
Does anyone out there have a possible solution? Thanks. -
[SOLVED] Changing Session variables between pages
A.White.89 replied to A.White.89's topic in PHP Coding Help
Is this something that is difficult or maybe I can simplify the question? -
Unfortunately, I do not know of any tutorials. But here is a suggestion: Use a database to hold times for a specific day. Then as you build your calendar, you can dynamically receive those days by database requests. If you understand how to use database requests effectively, you can make this happen
-
I am working on a session timeout functionality and I am having it timeout at 600 seconds of inactivity. This function, run at the top of each page, is: function timeoutCheck($activeTime) { $maxNoActivity = 600; // Seconds of session duration of no activity $difference = (time() - $activeTime); if($difference > $maxNoActivity) { session_destroy(); header("Location: login.php?timeout=1&page=".$_SERVER['PHP_SELF']); } } Then just below this function on each page the $_SESSION['activeTime'] variable is set to time(). So theoretically, $difference should be near 2-3 seconds if I refreshed the page every few seconds. Unfortunately, $difference always increases until 600 seconds at which time the session times out. To sum it all up, $_SESSION['activeTime'] is for some reason not changing between pages. It is never being updated to the new time (or at least the updated $_SESSION['activeTime'] is changing but not passing to other pages in the session). Note: All pages have session_start() at the top. Suggestions? Thanks.
-
[SOLVED] Inserting into database within a loop
A.White.89 replied to A.White.89's topic in PHP Coding Help
That wasn't the issue, but I figured it out. while($doc = mysql_fetch_assoc($doctors)) { $doctorID = $doc['ID']; mysql_query("INSERT INTO `askdoctors`(`convID`,`userID`,`doctorID`,`subject`,`content`,`category`) VALUES('$convID','$userID','$doctorID','$subject','$content','$category')")) } This worked fine. Thanks for the help. -
[SOLVED] Inserting into database within a loop
A.White.89 replied to A.White.89's topic in PHP Coding Help
Thanks for the response. Doing that just gives me "query completed" but still doesn't add multiple rows to the table. The problem wasn't that the query was failing, just that it wasn't inserting properly. (It didn't die). -
Well, you could use option 1 as a string of "Option 1" but it all depends on how you are using it and how you make it. To me, I would do: $option = 'Option 1'; if($session->prize == $option) OR if Option changes, $option = 'Option ' . $num; // However you give the number (loop, db, etc.) if($session->prize == $option)
-
I am trying to insert 2 or more things into a table with a foreach loop but for some reason only the first query is made within the loop. The script doesn't die but when I browse the table, only 1 of the rows is there. $query = mysql_query("SELECT `convID` FROM `askdoctors` ORDER BY `convID` DESC LIMIT 1") or die("Could not run query"); $lastID = mysql_fetch_assoc($query); $convID = $lastID['convID'] + 1; $doctors = mysql_query("SELECT `ID` FROM `doctors` WHERE `type` = '$category'") or die("Could not run query"); $insert = mysql_fetch_assoc($doctors); foreach($insert as $doc) { $doctorID = $doc['ID']; mysql_query("INSERT INTO `askdoctors`(`convID`,`userID`,`doctorID`,`subject`,`content`,`category`) VALUES('$convID','$userID','$doctorID','$subject','$content','$category')") or die("Could not run query"); } Any suggestions?
-
That worked great. I appreciate the help.