CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Can't get blasted Logout button working!

Print topic Send  topic

Author Message
jrr

Posts: 1
Posted: 01/21/2004, 2:11 AM


I need to include a Logout button on one of my pages, and this is what I did:

- Clicked on the 'Forms / button' icon, which added the button. Fine so far.

- Right-clicked 'Properties / Events / Server', and added a Logout action.

- Clicked Properties / Data, and selected the CCP file of the return page (the page where I want the button to redirect when pressed)

However, when I then publish the page and press the button nothing happens, and checking the code (the HTML and main PHP script for the page) there appears to be nothing that would trigger the OnLick event for the button.

I then tried setting up a Logout button, as above, on a brand new page, to ensure that CodeCharge Studio isn't skipping certain automatic code amendments (as it tends to do after one has manually tweaked the code), but still no luck.

I've also tried checking the CCS help text, but there seems to be hardly any explanation on setting up Logout buttons.

If anyone could explain how this is done, or point me in the right direction, that would be very much appreciated.


Cheers

John Ramsden (john_ramsden@sagitta-ps.com)

View profile  Send private message
jrr2
Posted: 01/21/2004, 3:02 AM

Cracked it :-)

The key is that an input spec must be enclosed in a form spec. You don't need any of that OnClick nonsense. Just add a button, called say Button1, manually change the value to 'LOGOUT' in the HTML, and enclose it in a form spec, as follows:

<form action="vplink.php">
<!-- BEGIN Button Button1 -->
<input name="{Button_Name}" type="submit" value="LOGOUT">
<!-- END Button Button1 -->
</form>

Then in the main PHP script, just before the redirect at the bottom, add a clause as follows, where 'main.php' is the main page of the app (or any page you want, in theory).

if (CCGetFromGet ('Button1', '') == 'LOGOUT')
{
CCLogoutUser();

$Redirect = 'main.php';
}

//Go to destination page @1-698EC839 <--- standard code from here
if($Redirect)
{

::: etc etc :::

Then when the user clicks the button, it will redirect to the same page, with the Button1 URL argument set to 'LOGOUT'. This will action the above clause, which will call CCLogoutUser() to clear the login session variables, and then redirect to the main page, which in turn will display the login screen ready for a new session. E voila - job done :-)

Cheers

John Ramsden
DonB
Posted: 02/04/2004, 3:23 PM

Yep. The reason? You must initiate a round trip to the server and unless
you have a form to post, nothing happens at the server end.

Alternately, you could create a link and set the URL to the current page.
Append a parameter to denote "log me out" and catch that in the Before Show
event of the page, where you can call CCLogoutUser()

--
DonB

http://www.gotodon.com/ccbth


"jrr2" <jrr2@forum.codecharge> wrote in message
news:2400e5c40f4215@news.codecharge.com...
> Cracked it :-)
>
> The key is that an input spec must be enclosed in a form spec. You don't
need any of that OnClick nonsense. Just add a button, called say Button1,
manually change the value to 'LOGOUT' in the HTML, and enclose it in a form
spec, as follows:
>
> <form action="vplink.php">
> <!-- BEGIN Button Button1 -->
> <input name="{Button_Name}" type="submit" value="LOGOUT">
> <!-- END Button Button1 -->
> </form>
>
> Then in the main PHP script, just before the redirect at the bottom, add a
clause as follows, where 'main.php' is the main page of the app (or any page
you want, in theory).
>
> if (CCGetFromGet ('Button1', '') == 'LOGOUT')
> {
> CCLogoutUser();
>
> $Redirect = 'main.php';
> }
>
> //Go to destination page @1-698EC839 <--- standard code from here
> if($Redirect)
> {
>
> ::: etc etc :::
>
> Then when the user clicks the button, it will redirect to the same page,
with the Button1 URL argument set to 'LOGOUT'. This will action the above
clause, which will call CCLogoutUser() to clear the login session variables,
and then redirect to the main page, which in turn will display the login
screen ready for a new session. E voila - job done :-)
>
> Cheers
>
> John Ramsden
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

guest
Posted: 02/21/2004, 6:43 PM

The easiest way I've found in CCS to do a logout is to bring up the
login page, and in the events inspector, select "After Initialize",
click "+" and select "Add code". In the resulting code space given to
add code, just check to see if the login button has been clicked, and
if not...log the user out. The results should look something like
this:

//Page_AfterInitialize @1-7910B30B
function Page_AfterInitialize()
{
$Page_AfterInitialize = true;
//End Page_AfterInitialize

//Custom Code @9-ADD652EE
// -------------------------
global $Login;
// Write your own code here.
if (strlen(CCGetParam("Button_DoLogin", "")) == 0) {
CCLogoutUser();
}
// -------------------------
//End Custom Code

//Close Page_AfterInitialize @1-379D319D
return $Page_AfterInitialize;
}
//End Close Page_AfterInitialize

There are other benefits to this. To log out, one only needs to go
back to the login page, whether by link, button, or typing in the url.
Another benefit is that you can put a meta-refresh at the tops of your
pages to log sessions out after a period of inactivity. Many of our
customers ask for this to prevent anything sensitive from being left
on screens.

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.