Results 1 to 4 of 4

Thread: If I want to destroy only part of a sessions' vars (php), what to do ?

  1. #1
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default If I want to destroy only part of a sessions' vars (php), what to do ?

    If I want to destroy only part of a sessions' vars (php), what to do ?
    setting mean destroyed ?

    $_SESSION['USERNAME']="";

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You can't really destroy values in the session data. You can change the session, which would then detach the old data, but it wouldn't even actually delete it from the server.
    So, the best way to do this is to replace it. If you want to replace the whole array, that works. If you don't want to lose all of it, though, like you say, then just replace each value with what you want.
    $_SESSION['somevar'] = ''; //set it to blank
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    PHP Code:
    unset($_SESSION['USERNAME']); 

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Tim, that will destroy the session. He just wants the value gone, so if you were to do if(isset()), it'd be true.
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •