Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to un-register a particular session variable from a session

    Hello,

    i need to unergister one or more than one session variables at a certain point in the code.

    I am just using plain session implementation using session_start()

    the thing is session_unregister is not working the way its written on php.net:
    PHP Code:
    session_unregister($_SESSION["var_name"]); 
    so is there any special technique i need to use.

    thanks in advance.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,024
    Thanks
    2
    Thanked 314 Times in 306 Posts
    The php.net page for session_unregister() also contains a couple of relevant pieces of information -

    Note: If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use unset() to unregister a session variable.
    If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister().
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by amirak17 View Post
    the thing is session_unregister is not working the way its written on php.net:
    be more specific, please.

    best regards

  • #5
    New Coder
    Join Date
    Apr 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i am using php 5.2.5

    i also tried earlier:
    unset($_SESSION['varname']);

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by amirak17 View Post
    i am using php 5.2.5

    i also tried earlier:
    unset($_SESSION['varname']);
    this is usefull, but what do you mean when you say "is not working the way its written on php.net"?

    best regards

  • #7
    New Coder
    Join Date
    Apr 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh by that i mean the session variable as well as its value stays in the session.

  • #8
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,024
    Thanks
    2
    Thanked 314 Times in 306 Posts
    Check your web server log for errors. Either the session is not starting so you are not really unsetting a session variable or there is a typo in the name of the variable. Your code could also be re-setting the session variable, so, posting your code would help someone to help you.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #9
    New Coder
    Join Date
    Apr 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    its solved now ... thanks

  • #10
    Senior Coder ahallicks's Avatar
    Join Date
    May 2006
    Location
    Lancaster, UK
    Posts
    1,134
    Thanks
    1
    Thanked 57 Times in 55 Posts
    Care to explain how for anyone else that has the same problem?
    "write it for FireFox then hack it for IE."
    Quote Originally Posted by Mhtml View Post
    Domains are like women - all the good ones are taken unless you want one from some foreign country.
    Reputation is your friend

    Development & SEO Tools


  •  

    Posting Permissions

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