maxhugen
Posts: 272
|
| Posted: 05/02/2008, 10:16 PM |
|
I'm setting a session variable during the login - the user's first name (say, "Pete"). Works fine.
But when the user logs out, my custom variable seems to remain, so although the user is back at index.php (where they can log in), and the CCS session variables have been cleared, you still see "Hi Pete".
How and where should I clear this session variable?
MTIA
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
maxhugen
Posts: 272
|
| Posted: 05/02/2008, 10:34 PM |
|
Sorry, just worked it out myself... I found the Logout code in Page_AfterInitialize, and simply set the session variable to an empty string.
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
DonP
|
| Posted: 05/02/2008, 10:37 PM |
|
If "Pete" is not their user logon name, it's better in my opinion to use
a CCDLookUp() to fetch their first name from the user table based on the
UserID rather than to set a session with the name. That way, when they
log out, the UserID session value should automatically disappear.
Otherwise you'll need to create an event for log out that wipes out the
session value.
I don't currently have CCS available on this system so unfortunately I
cannot provide an example.
Don (DonP)
maxhugen wrote:
> I'm setting a session variable during the login - the user's first name (say,
> "Pete"). Works fine.
>
> But when the user logs out, my custom variable seems to remain, so although the
> user is back at index.php (where they can log in), and the CCS session variables
> have been cleared, you still see "Hi Pete".
>
> How and where should I clear this session variable?
>
> MTIA
> _________________
> Max (99.3% CCS Newbie)
> "I have a dream..." that CCS provided a php debugger.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
|
|
|
 |
maxhugen
Posts: 272
|
| Posted: 05/02/2008, 10:56 PM |
|
Hi Don
Yes indeed... I do set UserID, GroupID etc, and these get removed AOK.
I saved the First Name (using CCDLookup) to the session so that I wouldn't make constant CCDLookup calls to the db, since my "Hi Pete" appears on every page once the user is logged in.
Old habits - keeping db calls to a minimum where possible. 
Cheers
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
tonyk
Posts: 163
|
| Posted: 05/03/2008, 10:12 AM |
|
In 'before show' or earlier page event how about
If(!CCGetUserID()){
//reset custom session variables
}
You could place this in your header file for the pages
Tony
|
 |
 |
DonB
|
| Posted: 05/03/2008, 1:30 PM |
|
http://us.php.net/manual/en/function.session-destroy.php
--
DonB
"maxhugen" <maxhugen@forum.codecharge> wrote in message
news:5481bf519dd7da@news.codecharge.com...
> I'm setting a session variable during the login - the user's first name
> (say,
> "Pete"). Works fine.
>
> But when the user logs out, my custom variable seems to remain, so
> although the
> user is back at index.php (where they can log in), and the CCS session
> variables
> have been cleared, you still see "Hi Pete".
>
> How and where should I clear this session variable?
>
> MTIA
> _________________
> Max (99.3% CCS Newbie)
> "I have a dream..." that CCS provided a php debugger.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>
|
|
|
 |
maxhugen
Posts: 272
|
| Posted: 05/03/2008, 5:11 PM |
|
Thanks Tony, Don!
I hadn't thought about how to handle things if the user doesn't explicitly Log Out. I'll try session_destroy() in the header include page, sounds good to me.
Cheers
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
|