Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 7th, 2008, 01:27 AM
Registered User
 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Session Related Issue

Hi,

I am using PHP4 and facing an issue regarding session control.

I have a login page login.htm which after taking required details e.g username and password, submits it to submit.php which has the following lines to control a session.

Code:
//submit.php
session_start();

$uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
$pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];

$_SESSION['lastaccess']= mktime();
After matching it with DB, it redirects to index.htm using header("Location:index.htm");

Now, Index.htm includes a php file called accesscontrol.php which has the following code :

Code:
//accesscontrol.php
session_start();
//header("Cache-control: private");
$newtime=mktime();

$tdiff = $newtime - $_SESSION['lastaccess'];
//echo $tdiff;
if ($tdiff > 900)
{
session_unset();
// Finally, destroy the session.
session_destroy();
exit;
}
else
{
$_SESSION['lastaccess']= mktime();
}
The problem is accesscontrol.php can't access $_SESSION['lastaccess'] which leads to further issues.

Please help.

Thanks in advance.

-Asmii
 
Old August 7th, 2008, 02:08 AM
Registered User
 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

On accesscontrol.php, $_POST variables are also not accessible.

Code:
$uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
$pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];
When I checked $uid and $pwd, these are not set.

Thanks.

-Asmii

 
Old October 5th, 2008, 07:06 PM
Authorized User
 
Join Date: Oct 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the $uid $pwd will not be available because you are using redirect and not include

for $_SESSION['lastaccess'];

try using double quote i.e. $_SESSION["lastaccess"];

and check if the your browser supports cookies

easy but not recommended way is to use include in submit.php to include index.php which then includes accesscontrol

thanks

http://FindaJobSearch.com
 
Old October 5th, 2008, 07:07 PM
Authorized User
 
Join Date: Oct 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

and if i am not wrong you are using 3rd party hosting which does n't gives access to php.ini so you are trying to control session time out manually

thanks

http://FindaJobSearch.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Related Issue Kirti.darji Visual Studio 2005 0 May 13th, 2008 06:40 AM
Zend Framework Related Issue Rajat Kumar Beginning PHP 0 May 6th, 2008 07:00 AM
Session issue with VWD Bob Bedell ASP.NET 2.0 Professional 3 December 26th, 2007 04:20 AM
VB5.0 to VB .Net upgradation issue related to DAO setu VB How-To 1 October 10th, 2007 03:15 PM
Session time out issue sameer_chandra Pro VB 6 1 July 31st, 2006 11:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.