0

Does anyone know whether I can removed a php session by using jquery or javascript?

1
  • do you mean the session in cookie?? Commented Dec 9, 2010 at 4:11

3 Answers 3

1

"Regular" cookies can be deleted in JavaScript using something along these lines:

This function will "delete" the supplied cookie from the browser by setting the cookie's expiry date to one second in the past.

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

If the cookie is a httpOnly cookie (a cookie with the httpOnly parameter set), you cannot read, change or delete it without closing the session (i.e. close the browser).

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

1 Comment

In case the OP doesn't know, the session is stored server-side, but a cookie is stored client-side with the session id. Thus deleting this session id cookie will remove remove the session.
0

Doesn't look likely. JavaScript has access to client-side cookies. Session cookies are set from the server.

Comments

0

jin we can delete a cookie in a page through javascript , but again if you go to some other page it will be set again from the server,

you can do a session off from the server

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.