CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Attention forum moderators!

Print topic Send  topic

Author Message
lwismanuel
Posted: 05/08/2005, 1:23 AM

Attention forum moderators!
It would be nice if you guys have a section (a howto) in this forum where the CCS coders could post their tutorials or solutions to some of the problem we (the coders) have already resolved. I am not that good my self with CCS but I get my way around in PHP. Some times when I do not know how to resolve a task in CCS I have to dig thru the entire forum for information. But, if we have a section where all the users contribute with what they have learned I think will be helpful for us the newbie.

Well, I will initiate the first post for this tutorial section. Pardon my English since is my second language.
If you are writing an application and you want to toughen the security by implanting a session-timeout (by saying session timeout I mean if a user is logged in and for whatever reasons there is no activities going on for a x amount of time he/she will be log out ) here is a way on how to do it:

/* first let`s set the time of inactivity for the users. In here you could hard-code
the inactivity time or retrieve it from the database, this would give more flexibility
to the admin user, using the CCDLookUp() function*/

$i_time = 10;

//now let`s format the time
$hour = date('H');
$mins = date('i');
$sec = date('s');
$mon = date('m');
$day = date('d');
$year = date('Y');

// this will create the time-stamp
$current_time = mktime($hour,$mins,$sec,$mon,$day,$year);

// and this line will make timeout
$timeout = mktime($hour,$mins+$i_time,$sec,$mon,$day,$year);

// if TIMEOUT session variable does not exist let`s create it
if(!CCGetSession('TIMEOUT'))
{
CCSetSession('TIMEOUT',$timeout);
}
// now let`s do the checking to test if the user has been active
if(CCGetSession('TIMEOUT') < $current_time){

// if not he/she will redirected to the page specified below
header('Location: ' . 'login.php');
}

// this line below is very import because this will refresh the timeout anytime the user navigate
// thru the application
CCSetSession('TIMEOUT',$timeout);
That’s it folks just paste the code at the end of your "Common.php" file.
If you detect a bug or make any improvement email me here:luis@citytek.net
peterr


Posts: 5971
Posted: 05/08/2005, 11:49 AM

Hi,
You can post your suggestions to the "Tips & Solutions" forum. It is available specifically for this type of posts.
Thanks.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
DSR
Posted: 05/23/2005, 10:31 AM

Hi lwismanuel !!!

I'm reading your post and I have some questions.

Where I put that code, inside a function?

And, how I call it?

Thanks!!
Lwismanuel
Posted: 05/25/2005, 2:03 PM

Hi DSR,

Just paste it at the end of the Common.php file that CCS generates. Since the Common.php file is included by default in all the pages you generate from CCS and the code is not inside a function you do not have to call it. If you feel more confortable putting the code inside a function do this:

function session_timeout ()
{
//put the code here...
}

session_timeout (); //let's call this function at the end of the Common.php

I forgot to mention that the interger in variable "$i_time = 10" represents minutes and not seconds.
RonB

Posts: 228
Posted: 05/30/2005, 3:23 AM

Isn't this something you'd normaly controll in php.ini? We just ste the session.gc_maxlifetime to a value we feel is secure. We do not want people leaving their pc unguarded while going for lunch whith admin pages open.
View profile  Send private message
lwismanuel
Posted: 05/31/2005, 9:03 AM

Hi RonB,

You are right but many developers do not have access to the php.ini. And doing it this way allows you to dynamically change the value without affecting other apps (globally), and killing sessions is easier.
Nicole

Posts: 586
Posted: 06/01/2005, 4:26 AM

Just a note: you can change session timeout in php.ini with ini_set() function
http://php.paco.net/manual/en/function.ini-set.php

_________________
Regards,
Nicole
View profile  Send private message
Alex G
Posted: 06/14/2005, 11:32 AM

;-)
I strongly agree that there are not enough examples and tutorials for the Codecharge product.

This is what I envision would help me at this time:

PROJECT EXAMPLE
1 Database 3 Tables (One lookup table)
2 page web site, log in page, add records (with search to lookup), update records

Simple but only handling the above cases with no other extraneous code.

Tutorial would include, tables and/or layout of tables and all necessary code.

Thanks!
Alex
peterr


Posts: 5971
Posted: 06/14/2005, 11:48 AM

Alex,

Not enough? Can you show me any other product that has over 40 examples and tutorials that CCS has :-)
Our main tutorial "Creating a Task Management System with the Application Builder" shows exactly how to create a multi-page Website with multiple tables, including search, list and update functionality, plus custom code for more advanced features.

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.