8

we all know that we can set and get session using javascript like below:

session.setItem("name", "value");  

session.getItem("name");

I need to know how to destroy particular and all session variable in javascript.

I used google but I'm unable to get exactly what I need. Please help me to find the solution. jQuery answers are also welcome (without plugin)

Thank you in advance

2

2 Answers 2

29

I assume this is session storage in html5, in which case you can use

sessionStorage.clear();

to remove all items in the session storage or

sessionStorage.removeItem('itemName');

to remove a specific item.

Sign up to request clarification or add additional context in comments.

Comments

1

clear(void):void This public method remove everything from the sessionStorage object.

https://code.google.com/p/sessionstorage/

I didn't test my self but I think it should work.

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.