![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4
![]() |
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... |
|
|
|
|
|
#2 |
|
Professional Programmer
|
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. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4
![]() |
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... |
|
|
|
|
|
#4 |
|
Professional Programmer
|
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. |
|
|
|
|
|
#5 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Well, you can also use PHP to output JavaScript - very handy when you're filling a JS array, for example.
|
|
|
|
|
|
#6 | |
|
Programmer
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4
![]() |
Quote:
__________________
I steal hippos... |
|
|
|
|
|
|
#7 | |
|
Programmer
Join Date: Jun 2005
Location: Amittyville
Posts: 60
Rep Power: 4
![]() |
Quote:
__________________
I steal hippos... |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|