[PHP] sessions terminating randomly please help
hi i am experiencing a major problem with sessions expiring randomly in some of my apps. i will log in and start clicking around and then i will eventually arrive at a page that tells me that i'm not logged in anymore. this happens apparently randomly. i have seen it on ie6, ie for mac, netscape 4.7 for pc, and mozilla the apps are hosted on freebsd 4.7-release p2 apache 1.3.27 php version 4.2.3 compiled with --enable-trans-sid i can't go into production if there's the possibility that users will be randomly logged off. i went through all of my code over the weekend, and i don't think i can attribute this to a miscoding: when a user logs in, i create a session with session_start(); $valid_user=$_POST['username']; session_register("valid_user"); i have the following code at the top of each page to check to see if the session is valid: session_start(); $valid_user=$_SESSION['valid_user']; global $valid_user; if (session_is_registered("valid_user") {...function to spit out an error message if the session is not valid...;} i have a logout page that destroys the session session_start(); session_destroy(); i also have a javascript timer in the header of every page that redirects to the logout page if the user has been inactive for 20 minutes. i have played around with session.gc_probability, setting it to 100, but that doesn't seem to have fixed the problem. this is a huge problem. if anyone can give some advice, i'd really appreciate it. thanks -- __ http://www.linuxmail.org/ Now with e-mail forwarding for only US$5.95/yr Powered by Outblaze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ok now my sessions are *not* timing out
before my problem was that my sessions were being terminated spontaneously. it looks like i've managed to fix that problem - so far i haven't been randomly logged off my application. the problem is, according to my php.ini settings, my session should have been terminated after 2 hours, it's been almost 5 hours now... my php.ini: ; Lifetime in seconds of cookie or, if 0, until browser is restarted. session.cookie_lifetime =0 ; Percentual probability that the 'garbage collection' process is started ; on every session initialization. session.gc_probability =100 ; After this number of seconds, stored data will be seen as 'garbage' and ; cleaned up by the garbage collection process. session.gc_maxlifetime =7200 after making the above changes in my php.ini, it looks like the javascript timer i have in the headers of my authenticated pages does not work anymore. this javascript is supposed to popup a warning message at 18 minutes of inactivity, and at 20 minutes, redirect the user to the logout page, which calls session_destroy(). the js looks like:
[PHP] convert VARCHAR 10 to DATETIME
this question is not strictly php related, but i thought possibly someone on this list might have dealt with this type of problem before. i am exporting a database out of filemakerpro 5 as a comma delimited file, and importing the data into a mysql database most of the information transfer over ok, the one big problem i have is filemaker's date/time format. in the filemaker pro database, it looks like the timestamp is stored in the format: M/DD/ mysql will not let me create a DATETIME field with X/XX/ as the default value. it automatically changes the default value to '-00-00'. i will migrate the filemaker pro data, using VARCHAR 10 to store the timestamp information, but there needs to be a way to go through every entry in this column, convert a string such as 'M/DD/' to something compatible with mysql's DATETIME format. the reason i'd like to convert the filemaker-generated 'M/DD/' timestamp string, which would be stored as VARCHAR in the db - to something like '-00-00' - is that i'd like to convert the the data type of this field from varchar 10 to DATETIME with a default value of -00-00, so that any sql queries searching through the database by date will be compatible, as will any future entries that get tacked onto this field in the database after the migration from filemaker, which will be in DATETIME format i don't know if this can be accomplished by php, or some other type of scripting language. i'd like to avoid having to manually edit the timestamp information if i can avoid it... if anyone has any suggestions, i'd really appreciate it thank you -- __ http://www.linuxmail.org/ Now with e-mail forwarding for only US$5.95/yr Powered by Outblaze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] convert VARCHAR 10 to DATETIME
thanks. this was the quickest way to accomplish the task strtotime(); also works. both are useful to know... - Original Message - From: "John W. Holmes" <[EMAIL PROTECTED]> Date: Wed, 19 Mar 2003 21:47:23 -0500 To: "'freaky deaky'" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> Subject: RE: [PHP] convert VARCHAR 10 to DATETIME > > i am exporting a database out of filemakerpro 5 as a comma delimited > file, > > and > > importing the data into a mysql database > > > > most of the information transfer over ok, the one big problem i have > is > > filemaker's date/time format. > > > > in the filemaker pro database, it looks like the timestamp is stored > in > > the > > format: M/DD/ > > > > mysql will not let me create a DATETIME field with X/XX/ as the > > default > > value. it automatically changes the default value to '-00-00'. > > > > i will migrate the filemaker pro data, using VARCHAR 10 to store the > > timestamp > > information, but there needs to be a way to go through every entry in > this > > column, convert a string such as > > 'M/DD/' to something compatible with mysql's DATETIME format. > > > > the reason i'd like to convert the filemaker-generated 'M/DD/' > > timestamp string, which would be stored as > > VARCHAR in the db - to something like '-00-00' - is that i'd like > to > > convert the the data type of this field > > from varchar 10 to DATETIME with a default value of -00-00, so > that > > any sql queries searching through the > > database by date will be compatible, as will any future entries that > get > > tacked onto this field in the database > > after the migration from filemaker, which will be in DATETIME format > > If you want to do it strictly in SQL, then use MySQL's String functions > to pull apart the M/DD/ date and format it into a valid MySQL Date. > > If you can run the whole thing through PHP, you may be able to use > strtotime(). > > For the SQL solution, create a new column in your table that is a Date > type. We'll call it f_date for this example. The following query will > break apart the M/DD/ and format it as /MM/DD, which is a format > MySQL will accept. > > UPDATE table SET f_date = CONCAT(RIGHT(old_date,4), '/', > SUBSTRING_INDEX(old_date,'/',2)); > > Hope that helps. > > ---John W. Holmes... > > PHP Architect - A monthly magazine for PHP Professionals. Get your copy > today. http://www.phparch.com/ > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- __ http://www.linuxmail.org/ Now with e-mail forwarding for only US$5.95/yr Powered by Outblaze -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php