简体   繁体   中英

PHP unset session in method

i have created a custom class to manage all types of session

i have created few static methods but for unset its giving me an error

 public static function unsetSession($para) {

     return unset($_SESSION[$para]);

    }

Can nay one give an idea why its throwing error

I read php document

Description

void session_unset ( void )

The session_unset() function frees all session variables currently registered.

Return Values

No value is returned.

is it unset is not returning ?

Thanks

Getting following Error

Parse error: syntax error, unexpected 'unset' (T_UNSET)

Have you tried this?

public static function unsetSession($para) {
    return session_unset($_SESSION[$para]);
}

unset() destroys the specified variables.

The behavior of unset() inside of a function can vary depending on what type of variable you are attempting to destroy.

If a globalized variable is unset() inside of a function, only the local variable is destroyed . The variable in the calling environment will retain the same value as before unset() was called.

Read here : unset

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM