Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 2nd, 2005, 10:23 PM   #1
squishiful
Programmer
 
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4 squishiful is on a distinguished road
On Session End

Can you run a command when a session is ended by closing the browser or deleting the cookie or something other than session_destroy? Thanx!
__________________
I steal hippos...
squishiful is offline   Reply With Quote
Old Sep 2nd, 2005, 11:40 PM   #2
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
Well, yes I guess. You could set javascript to, on close, set a cookie variable like "$session_kill = "yes" ". And at the beginning of your php code you can have it execute a function that says "if $session_kill == "yes" { session_destroy(); }"

The session won't be killed on browser close, but if they try to open it after closing it will be killed. I'm pretty sure you have to use the session_destroy, but you can combine it with other things, not just a logout page or something.
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Sep 3rd, 2005, 11:08 PM   #3
squishiful
Programmer
 
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4 squishiful is on a distinguished road
That confuses me...
So are you saying that javascript and php can work together, if so, why didn't I know that... w/e. Can you show me some example code? Thanx!
__________________
I steal hippos...
squishiful is offline   Reply With Quote
Old Sep 3rd, 2005, 11:42 PM   #4
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
Not off the top of my head. But the only thing that javascript and PHP can work together on is cookies. Algorithm/event sequence would look like this:

User closes window (PHP session is still going)
Javascript action (on window.close or something like that) comes into play, sets a cookie variable called "Session_Kill" and gives it the value of "yes"
User opens the browser back up, goes to site.
PHP function is called (set to call everytime the site is checked) to see if there is a cookie variable called "session_kill" and what it's set to.
If the variable is set (which in this case it is), then php destroys the session.
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Sep 4th, 2005, 6:00 AM   #5
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Well, you can also use PHP to output JavaScript - very handy when you're filling a JS array, for example.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Sep 5th, 2005, 9:49 PM   #6
squishiful
Programmer
 
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4 squishiful is on a distinguished road
Quote:
Originally Posted by Ooble
Well, you can also use PHP to output JavaScript - very handy when you're filling a JS array, for example.
That be true!
__________________
I steal hippos...
squishiful is offline   Reply With Quote
Old Sep 5th, 2005, 9:50 PM   #7
squishiful
Programmer
 
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4 squishiful is on a distinguished road
Quote:
Originally Posted by Lich
Not off the top of my head. But the only thing that javascript and PHP can work together on is cookies. Algorithm/event sequence would look like this:

User closes window (PHP session is still going)
Javascript action (on window.close or something like that) comes into play, sets a cookie variable called "Session_Kill" and gives it the value of "yes"
User opens the browser back up, goes to site.
PHP function is called (set to call everytime the site is checked) to see if there is a cookie variable called "session_kill" and what it's set to.
If the variable is set (which in this case it is), then php destroys the session.
Thanx!
__________________
I steal hippos...
squishiful is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:31 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC