0

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)

5
  • what error you are getting? Commented Mar 24, 2017 at 5:07
  • @ChetanAmeta.updated question Commented Mar 24, 2017 at 5:08
  • Is this to do with codeigniter or laravel two different frameworks Commented Mar 24, 2017 at 5:10
  • 1
    If codeigniter codeigniter.com/user_guide/libraries/sessions.html Commented Mar 24, 2017 at 5:10
  • @wolfgang1983.i am using core php Commented Mar 24, 2017 at 5:10

2 Answers 2

3

Have you tried this?

public static function unsetSession($para) {
    return session_unset($_SESSION[$para]);
}
Sign up to request clarification or add additional context in comments.

2 Comments

@carl.ya thats working may i know why unset is not working
Because unset is not even a function. And based from your description, it is clearly said that "The session_unset() function frees all session variables currently registered."
2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.