session destroy problem

Reply

Join Date: Jul 2008
Posts: 13
Reputation: prashanth18 is an unknown quantity at this point 
Solved Threads: 0
prashanth18 prashanth18 is offline Offline
Newbie Poster

session destroy problem

 
0
  #1
Aug 27th, 2008
hi
when i click the previous page button it was gng to logout page the sesion was not destroying when iwas using this code please help me


  1. <?php
  2. session_start();
  3. session_unset($_SESSION['uname']);
  4. session_destroy();
  5. header ("Location: login.php");
  6. ?>
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: session destroy problem

 
0
  #2
Aug 27th, 2008
try this code:
  1. session_start();
  2. session_unregister('uname');
  3. session_destroy();
  4. header ("Location: login.php");
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: session destroy problem

 
0
  #3
Aug 27th, 2008
all you need to do to destroy a session is call

  1. session_destroy();

you don't need to unset variables before then.

session_unregister is depreciated anyway.

if you want to remove something like the uname part of the session array just use

  1. unset($_SESSION['uname']);
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 849
Reputation: R0bb0b is on a distinguished road 
Solved Threads: 67
R0bb0b's Avatar
R0bb0b R0bb0b is offline Offline
Practically a Posting Shark

Re: session destroy problem

 
0
  #4
Aug 27th, 2008
I've always just done
  1. function destroy_sess($sessname = "all sessions")
  2. {
  3. if($sessname == "all sessions")
  4. {
  5. $_SESSION = array();
  6. }
  7. else
  8. {
  9. $_SESSION[$sessname] = NULL;
  10. unset($_SESSION[$sessname]);
  11. }
  12. }
and that works fine for everything that I do.

BTW: session_unregister() is not forward compatible with php6
Last edited by R0bb0b; Aug 27th, 2008 at 7:46 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss

-- The documentation is inevitable, you may get away with it for a little while but eventually you too will have to do the deed.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC