LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-18-2004, 02:02 PM   #1
Linh
Member
 
Registered: Apr 2003
Posts: 178

Rep: Reputation: 30
session timeout for cookie does not work


I have a two php page: users-authentication.php and
session.php. The page users-authentication.php is a php page that contain HTML code and it is to be displayed on a web browser whereas the session.php is to be run on the back-end and it is non-displayable.

The page users-authentication.php called session.php as shown below. For simplicity, most of the code for
users-authentication.php is not shown, but all of the code
for session.php is shown below.

If the page users-authentication.php is closed and then I open a new web page and go to users-authentication.php again, it asked for a username and password. This works.

If I do not close the page and waited for 15 minutes or after and then I clicked on certain part of the users-authentication.php web page, it still let me clicked on it. Instead, it should have directed me to the index.py page
because the time out was set for 15 minutes.


//////////////////////////////////////////////////////////////////////

Code:
//users-authentication page

<?php
//users-authentication.php

//The page session.php is below
@require( "session.php" ) ;

// Ensure we have a proper session.
// The function below resided within session.php
checkSessionCookies( ) ;

?>

////////////////////////////////////////

<?php
// session.php page
// Session handling/management functions for logging in.


// Set session timeout here for 15 minutes
$_LIFETIME_ = time() + ( 15 * 60 ) ;
@session_set_cookie_params( $_LIFETIME_ ) ;

// Note:  Defaults to ending when browser is closed.

function checkSessionCookies( )
 {
   global $HTTP_COOKIE_VARS ;
   global $HTTP_SERVER_VARS;

   if( !strlen( $HTTP_COOKIE_VARS[USERNAME] ))
    {
      // Not logged in; redirect.
      Header( "Location: index.py" ) ;
      exit ;
    }
   global $HTTP_SESSION_VARS ;

   $HTTP_SESSION_VARS[userid] = $HTTP_COOKIE_VARS[USERNAME] ;

   if( !strcmp( $userid, "admin" ))
     return 2 ;
   else
     return 1 ;
 }
?>
 
Old 08-18-2004, 02:19 PM   #2
lackluster
Member
 
Registered: Apr 2002
Location: D.C - USA
Distribution: slackware-current
Posts: 488

Rep: Reputation: 30
I believe this will help you: http://www.mambers.com/showthread.php?t=4685
 
Old 08-18-2004, 02:42 PM   #3
Linh
Member
 
Registered: Apr 2003
Posts: 178

Original Poster
Rep: Reputation: 30
reply

Thank you lackluster for your help.

What is the function that I would use to access the time that was set on the cookie ?
Is it getCookie() ? I tried abc = getCookie() but it does not work.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
kde.org cookie at session start?? Kerrysl Fedora 7 10-24-2005 06:22 AM
lose telnet session (timeout ? - putty) alexia AIX 7 08-17-2005 07:47 AM
How to change the timeout on a telnet session? gimpytoday Linux - Networking 1 06-23-2004 10:24 AM
wu-ftp session timeout howto? heatlill Linux - General 3 04-02-2003 05:04 PM
proftp session timeout artman62 Linux - Networking 2 01-08-2003 02:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration