Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How To Implement Timeout Warnings For Session Expiration?


I am looking for some examples on how to inform the user that their session is about to expire. I would like after some period of user inactivity to display a message that their session will expire and that they will be logged out. I also would like to include in this message asking the user to click a button to stay logged in. I am looking for examples that implement this feature in PHP.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Session Expiration
I have a site where I set a session cookie that expires in 1000 days.

As part of my script,. I create a $_SESSION["variable"].

Now, I am wondering, if the user closes their browser window and, for
example, come back to the site next week, will the session variable still be
there?

Session Expiration?
Is there away that you can get session_dat files to delete themselves after a cetain time limit? Im running PHP sessions over quite a busy site, So for every hit, a new session is started. Is there away that I can control this so over time i dont have a huge build up of obsolete session files?

Session Expiration
Let's say you set a session to expire in 20 minutes. Does reading and/or writing a session value bump that time up each time, or does it expire 20 minutes from when it was first created? I am pretty sure it is the former, but I want to check to make sure.

Setting Session Expiration?
I am having trouble with PHP 4 on Mozilla/Firefox. How do I set
the expiration date (within my PHP code) for the cookie created by

session_start();

I tried

session_set_cookie_params(time() + 3600);
session_start();

but when I check Firefox's cookie settings, it says my cookie is set to
expire at the "End of Session". Shouldn't it say a time?

Session+cookies Expiration
I just started to use/learn php session and cookies. Everything looks fine,
I took a quick look at the php session man pages but there's two little
things that I can't figure out completely.

1- A simple page to see what happens behind the scene:
<?
session_start();
$_SESSION['TEST'] = "This is a test";
phpinfo();
?>

Session config looks like this:
session.cache_expire = 30
session.cookie_lifetime = 1800
session.gc_maxlifetime = 1440

phpinfo() show the following HTTP Response Headers :
Set-Cookie: PHPSESSID=sgkddlmuepiksd48pq1tmj38s0; expires=Sat, 21-May-2005
10:38:41 GMT; path=/
[Which is ok ... cookie will expire in 30 minutes (1800 seconds)]
EXPIRES: Thu, 19 Nov 1981 08:52:00 GMT
This is the one I don't understand, what is it, where does this value come
from? And it's always the same exact date/time. ?!?

2- The session files in D:TEMP are not removed. I thought that those files
would be removed after some time (maybe I'm just not patient enough).

Session Warnings
I am have a form on the page registration.html the content is posted to a page called registration.php Although the database is getting populated, i am having problems with the session variables. I get the following errors:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /usr/shared/web/intocore/registration.php:10) in /usr/shared/web/intocore/registration.php on line 41 Code:

Session Timeout
In ASP I can use the various Session event handlers inside an global.asa file to make an action when the session expires.

Is there a way I can do the same with PHP?? I mean, I set a session to expore after 30 mins, and I want to do some cleanup (database related) work after it has timed out?

Session Timeout
I am using following statements in my file for keeping my session live for 24 hours

session_start();
session.gc_maxlifetime = 86400;

but is giving parse error on line 2. what could be the problem and what is the solution for keeping the session live for 24 hours ?

Session Timeout
I am implementing a site which will be used in an intranet by a limited
number of users. The web server i am using is WIN2003 / IIS 6.0 / PHP 5. I
want to enable sessions that will not timeout even after a long time (3-4
hours).

Having read some of the documentation i concluded that i should set
session.gc_maxlifetime and session.cookie_lifetime in my php.ini
appropriately, i.e. session.gc_maxlifetime=14400 and
session.cookie_lifetime=0. Am i right at this?

Furthermore, i am wondering if i should set IIS appropriately, does it
intervene with session data(sent session cookies)? I think that Apache does
not but i am not sure about IIS.

PHP Session Timeout
Is it possible to set x seconds interval for the "Garbage Collection"? So the PHP deletes inactive session files after x seconds rather than waiiting for session triggering to start the garbage colletction.

PHP Session Timeout
I've modify the php.ini the session.gc_maxlifetime to reduce
the time of timeout of the session variabiles.
But it not seems to go. In fact the session variabile remain
also when after the timeout that i've set.

Session Timeout
How long does it take for a session to timeout,if I have a user logged in on my site, how much time of inactivity will it take before the session is automatically destroyed and they become logged out,i do not use cookies,I have these values in my php info

session.cache_expire   180
session.gc_maxlifetime   1440
session.gc_probability   1

from what I understand the session is destroyed after 180 minutes of inactivity,but the session has a 1% chance of being garbage collected after 1440 seconds of inactivity (is this destroyed?)

so if I wanted all sessions destroyed after the 1440 seconds, should i set the probability to 100

or should i change the
session.cache_expire   180

to something that would suit me better, i.e. the 1440 seconds,

i.e.
session.cache_expire   24,

would this always delete the session after 24 minutes,or do both values have to correspond etc,

Session Timeout...
I want sessions to time out and get destroyed if the user has been idle for more than x time...

I already have it so a timestamp is created and sent to the database per user every time they visit a page... so I have this timestamp available...

I know you use session_destroy() to destroy a user's session if they visit the link but is there anyway to have a script that say mass destroys sessions based on how old the timestamp is?

Using Session Timeout Without Cookies
I am working on a PHP project where the client is telling me to make a session timeout after 1 hour. I am not using cookies in my site. But as per the php.ini file on the server the timeout had been set to 180 secs (by default), hence the page expires after 3 minutes. Now I need to make this work by setting the session timeout upto 1 hour.

Session Timeout, Use Of Sleep Ect...
I have a custom script that uses sessions to track UID's. The only problem I have with the script is that the session times out in 1440 (min?) which I believe is 24 min. I was thinking that I could use php's sleep to hold off from doing a refresh until minute 20.

Unfortunately, I have also read that using sleep can leave a server open to a DoS attack.
I do not have access to the php.ini file to be able to change the timeout variable for the session. What is the best way to keep a session open without changing the .ini variable. Is sleep a good way do go about it, and if so, are there significant security risks in using sleep()?

Session Timeout Question
Can I adjust the PHP session timeout on my web site? Users are
reporting timeout errors when they leave their computer for a period
of time and then come back to resume using the site - is there some
kind of global session timeout in PHP that I can set?

PHP Session Default Timeout
what is the default Session Timeout for php...is there a way to increase this on the web server I am hostign my php scripts on..

Stupid Simple Session Timeout......?
Is there a stupid simple way to end sessions automatically after a certain amount of inactivity-time?

How To Session Timeout For Specific WebPage ?
I would like to know how to set the session timeout time
locally and not globally in the php.ini file.
I do that as it is ine www.php.net but doesn't seem to do anything
/***************************/
/* set the cache limiter to 'private' */

session_cache_limiter('private');
$cache_limiter = session_cache_limiter();

/* set the cache expire to 1 minutes */
session_cache_expire(1);
$cache_expire = session_cache_expire();
/******************************/
I enter 1 minute for testing purposes....
- Also It would be helpfull to let me know how I am going to verify that
the session has been expired....
- Is there any way to automatically refresh the page when the session has
expired and let the user know ?
- Is there any good site that I can find tutorials or examples for this
purpose?

Executing Code On Session Timeout
is it possible to execute some code on the session timeout event?
i.e. clear all db information and other stuff when the php session is
destroyed through the gc_maxlifetime timeout.


Session Timeout Suggestions Wanted
I have a form where users logged in using sessions can edit articles in
a WYSIWYG editor. Some of them take their time and don't like to save
their work very often and occassionally the sessions expire and their
work goes poof. (I've suggested editing off-line and simply copy+paste
but they prefer the editor.)

After a lot of searching I've found the main culprit is
session.gc_maxlifetime and I can set it longet like...

ini_set('session.gc_maxlifetime', 7200); // 2 hour inactive session
timeout

Are there other timeouts I should worry about with Apache/Linux?
(Caches, etc..?) My other php.ini settings are...

session.cache_expire180 -> 3 hours shouldn't be a problem
session.cookie_lifetime0 -> this is don't expire while browser open
right?

Now a few of my Google searches came up with a scenario for timeouts
where the timezone of server and client have to be considered. i.e. If
server is ahead of client by 1 hour, is the session timeout reduced by 1
hour for that client. Can this be true??

Also are there any other problems with a php session lasting 2 hours?
Small site, not a lot of users with these priviledges or accessing the
editor.

Curl Timeout Vs Socket Timeout
We have two versions of client code, one using curl, and other one using raw sockets via fsockopen(), and we use the following code to set the i/o timeouts:

1) curl:
.
.
curl_setopt( $handle, CURLOPT_TIMEOUT, 1 );
.
.
$resp = curl_exec($handle)

2) sockets:
stream_set_timeout( $sock, 1);
Here we use frwrite() and fread() to send the request and read the...

Page Expiration
how can i avoid the "warning: page expired" message when going back to a dynamically generated page that was created after a form was submitted (this only happens after forms are submitted). I'd be SO greatful if you know how to fix this. And no, using the GET method instead of POST doesn't work for me and I don't want to do that anyhow.

Date Expiration
I'm wanting to have a button on my website for each blog post, however if the blog post is 5 days old it will not display the button on the page. What would be the best way to do this?

How To Get Rid Of Warnings?
I have the maximum number of warnings during PHP development. How can I
get rid of these warnings without turning them off in PHP?

Here's the code I have:

PHP Warnings
Anyone know how to disable non-fatal PHP warnings from appearing in the
browser when the PHP file is run? My code is ok I think, the results are as
expected, but im getting warnings appearing in the browser with the expecte
outputs.

How To Implement Such A PDF Form
I am developing a web site with PHP and MySQL.
There are many forms that need to be generated
based on users' information in database, and
then let users to complete the rest. Finally
the users can print and sign the forms.
I think a good way to implement this application
is to use Adobe Acrobat to compose form templates
in advance. When a user request a form by
internet, I will make a copy of its template,
and fill some pre-designed entries with his info
from the database, and then let him to view it.

My questions are
1) how can I fill these pre-designed entries with
PHP?
2) Is there any other better way to implement the
application?

Membership Expiration System
i have a website where user can sign up for either two months or four months Membership,
i want to make a sytem that can expire their membership automatically after the decided time period. is there anyway to handle this without using cronjob? and if cronjob is the only way to do so then can anyone give me a link to a good tute or article ?

Domain Expiration Date?
I need to to query internic (or another domain DB) for the expiration date of domain names. All I need is the expiration date nothing more. So how would I do that? Where can I find some info on doing that? any tutorials around for something of this nature?

MySQL Data Expiration
Well I have to make a "job search" for a temperary staffing company. What i have to do is make a control panel for staffing coordinators that will allow them to post jobs. That is the easy part. I have to set an option on the form to make this automaticly expire after a certian amount of days. Like if the job starts next week, I'll have it expire in 7 days.

Sessions And Page Expiration
im trying to make a search engine with a login using (much like craigslist). problem is - when i start a session, none of the pages are cached so the page expires after the user views a result, and cant get back to the results page.

Header Warnings? Why?
// REDIRECT THEM BACK TO LOGIN
if ($hasSubmittedUsername) {
header("Location: http://$SERVER_NAME/fslogin.php?errorMsg=" .
urlencode($font . '<font color=000099><li>Password
emailed</li></font></font><p>') .
'&username=' . urlencode($username));
}

?>

<html>
<head>
<title><?= $brand ?> Login: Forgot Password</title>

Based on this code snippet (and there is nothing being written to the
headers prior to header("Location.."), why am I getting the following:

Warning: Cannot add header information - headers already sent by (output
started at /home/youth/finesocceryouthsessions-www/fsforgot.php:15) in
/home/youth/finesocceryouthsessions-www/fsforgot.php on line 114

The line is the header() line. Furthermore, instead of being redirected to
fslogin.php I am still at fsforgot.php! Can someone help me quickly, I'm on
a tight deadline!

Header Warnings? Why?
I have an index php page which has the following code within a header
redirect:

<?php
if ( empty($_GET['month']) )
if (empty($_GET['year']) )
{
$month = date(n);
$year = date(Y);
header("Location: index.php?month=$month&year=$year");
}
?>

On the same index.php page, I have a shoutbox (include file) which inputs
the content of the shoutbox form into a database. After the user fills out
the form, I want the index page to refresh again because if I leave it as it
is and a user inputs info into the form, if they press refresh, the form
resubmits thus recording two entries into the shoutbox, or however many
times refresh is pressed.

When I add a header redirect into the shoutbox include file, once the user
clicks on send, index.php throws a headers cannot be sent error message.

Best Way To Implement A Search Feature
i'm asking here, this may not be the right place, but...

i want to implement a search feature on a site. for the most part, all data is in the php files, not a db.

is there a clever, low-impact way to do this?

At What Point Should I Implement Validation?
I am designing a relatively simple CMS with the usual Item, Category and
User scenario. My question here relates to how I implement the User
registration on this application. Currently I have the following:

register.php
classes/class.Form.php
classes/class.Validation.php
classes/class.User.php
classes/class.MySQL.php
templates/register.tpl.php

The thing that is really bugging me is how I perform the validation on what
is entered on the register.php page?

My first version (which I actually coded) simply created a new instance of
the Validation class on the register.php page then performed numerous if
statements with an error increment counter and if that returns zero (once
all the tests are completed) then proceed else redisplay registration.php
page. Works OK but looks terribly ugly and I am convinced there are far
better approaches.

My second idea is to use CRUD methods within the User class and have the
User class call the validation directly.

My third idea was to somehow apply the validation rules to the form objects.
I have seen that some frameworks use this method but my problem is that I am
really bad at understanding other people's code.

I keep hearing the term "design patterns" and just wondering if reading a
book or two on that subject might clear my head on how to progress forward.
The problem is not that I cannot code this, it's the approach I should take
and would value some opinions by the piers of the group.

How To Implement Gzip-compression
I want to try out gzip-compression on some of my PHP-scripts. How can I do that? Currently I'm developing on Windows 2000 with latest Apache and latest PHP. My service provider runs Linux and PHP. Do I have to add code to my PHP-script or does the server handle the "gzipping" transparently? Do I have to do anything special to Apache? To PHP? If Apache needs to be "altered" in some way, will the PHP-scripts still work if it isn't?

How Do I Implement HMAC-MD5 In PHP4?
I'm using PHP 4. I'm trying to build a form to send payment
information to Authorize.Net. In the documentation for their "Simple
Integration Method 1.0" they say I need to generate a fingerprint using
logic like:

FingerPrint =
HMAC-MD5("$merchant_login^$invoice_num^$timestamp^$amount^",
"$transaction_key")

Does anyone know what the HMAC-MD5 equivalent function is in PHP?


Good Way To Implement [nocode]?
I'm working on being my own BBcode parser, but I would like to get this out of the way before continuing.

Please can somebody tell me a good way to implement [nocode] tags? The only ways I can think of are very bad/hacky solutions I think and have a chance of getting messed up.

I was going to post an example but it seems this forum doesn't support [nocode] :/ but basically if there is an opening element before the nocode, and a closing one INSIDE IT, it would get messed up..

The only way around this I can think of is like randomly making a string of random characters and putting the stuff between the nocode tags into a subarray of that and then deleting it from the text and replacing it with the string of random characters, and later putting them back in after all the interpreting is done.. but I think that this is an extremely hacky of doing it and probably not very good performance either.

Getting Cookies Expiration Date And Time?
Is it possible to get the expiration date/time of a cookie?
I need to limit someone to visiting a couple of pages for 45 minutes
max and would like to show them how much time they have left. I dont
think a javascript timer will work, because the timer should continue
where it left off at on the previous page.

Certificate Expiration For Remote Server
I've been looking for a function or a couple of functions which will allow me to get the Certificate Expiration date for a given website. I've tried openSSL, but their functions only seem to work on the current server, which is useless to me because my server doesn't allow SSL or certificates. I just want the certificate of an external website, e.g. www.gna.org has a certificate (signed by themselves, but a certificate nonetheless).

I've also tried cURL, since that allows you to access a remote server, but that will just check their certificate - it doesn't offer any functionality for e.g. checking when it will expire.

Relative Include Warnings
For some reason, relative include paths that go DOWN in the directory structure (../) are giving me warnings. PHP Code:

Handling Warnings, Php5?
I need to handle warnings in incorrect regular expressions executed
using preg_match.
Warnings shouldn't appear, instead I want to output some generic
message like: "Bad regex: $regex" and also do a database change.
I tried using try-catch but warnings are not caught.

Apache Startup Warnings -PHP 5.1.0-dev
Apache/2.0.53 RHE3 WS
PHP 5.1.0-dev --enable-debug
libxml 2.6.20

I decided to give the latest PHP5 a try since it's including some
updates I really need (PDO_SqLite, Soap, etc yayy) and after having to
upgrade libxml I'm getting the following warning when performing a
graceful restart with Apache.

Cannot load /usr/lib/apache/libphp5.so into server:
/usr/lib/apache/libphp5.so: undefined symbol: xmlResetError

The build etc seemingly works fine so far, and I only get this error
message when doing a graceful restart, not with a start/stop.

I've done a similar build with 5.0.3 with no warnings.

How To Implement Automatic Invocation Of A Script
am trying to implement a mail redirectional script by reading the POP3
server mails.

ie all d mails which comes under <anyone>@companyname.com will
redirect to <anyone>@<hisowndomain(yahoo,gmail,...).com>

ok whtevr it iss

i want to know in which are all the way i can excecute this script.

choice#1: i will hav a php script dat will refresh in each minutes.
Here i need to keep a window open to run the script in any machine.

Choice#2 :is der any way to do the same in server

What Is The Best Way To Implement User Mailbox On A Site?
what would be the best way to implement user mailbox on a site, it should be similar to 'use cp' in this forum. I don ot have an email server although that would be nice, i have access to a mysql db. Oprion A: if I go with the database (which seems most logical to me at the moment) how should I set up my tables in db if there is an example out there please point me to it.

Is It Possible To Use PHP To Implement Tiddy Shopping Cart?
I design sites for small business and some of which only sell around 10 items. Therefore I do not want a whole new system like zencart or OSCommerce. I want to implement a tiddy little shopping cart into my 800pix wide content box. I can design the system of adding e.t.c myself but, as for actually processing a transaction, I have no idea where to start.

How To Implement Pagination To A Download Script
I have no idea how to implement pagination to this script. Could anyone please advise me which file I should look at and how to implement a simple pagination that will allow me to display 20 devices for each list page. Code:

Php Function To Implement C Language Programs
I want to know of a function in PHP that will allow me to run C language code. I am using a C library, for that I need to write C code. So how can I incorporate C code in a PHP program.

Handling Include() & Require() Warnings
require() and include() both load up a file. require() exits if the
inclusion fails while include() issues a warning and the script
continues. In the latter situation how should I detect the failure?

include('Foo.php');

if (...) {
Foo::do_something();
} else {
backup_action();
}

What should the test be? Can I catch the warning thrown by the
include()? Should I search through get_included_files()? The
file being included is a "standard" one which might be missing from an
installation, so I can't edit it to define a constant in it.


Copyright © 2005-08 www.BigResource.com, All rights reserved