954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to expire a session

I am new with session.

What i am trying to do is that if someone doesn't visit my site for lets say 5 day i want the session to expire. is there a way to do this as i am not aware of it.

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Sessions are set automatically by the server on page load, and the default life of a session is 20 minutes. If you are overriding this setting (which is acceptable) and you are setting it to ndays (which is highly unnacteptable) then you are putting an incredibly heavy load on your server memory and will cause a whole load of pain for yourself.

It may help our understanding of your situation if you detail exactly what sessions you are refering to and how they are being assigned.

Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

then tell me this when an a session expire is it deleated on the server as i use sessons and they just take a lot of space on the server because for some reason they are just gathering there

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Have you changed the default session lifetime? How are you setting the sessions?

As stated, server sessions are managed automatically by the server, but some of the defaults can be overridden by code.

Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

I havent messed with any part of my server as i use yahoo server and they dont let me change any thing in it.

If you wana look at my server setting you can find them at http://www.eezs.com/test/test.php

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Well the server settings are all kinda standard, so no problem there. I noticed you are setting a cookie named BX and you have set a life of 5 years on it. Is this what you are referring to?

Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

I have no idea what that cookie is so i dont need 2 worry about it but is there a way to forcefully expire sesson and delete it from the server so they dont just sit there and pile up.

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Still have no idea what sessions you are refering to. Can you post a screenshot of the sessions you are talking about? Where are the 'sessions' being stored? If you are physically setting a session variable or persistent cookie then you can delete/expire/unset that session variable based on a time calculation. If the session variable is a server generated session variable then it will expire automatically based on the lifetime setting in the server.

Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

basically what i am asking is how to expire session after certain period of time.

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

There are couple of methods depending on how the sessions are set and how much of the session data you actually want to destroy.

Have a look at using session_destroy, session_unset, unset('$_SESSION['$varname']), or session_write_close. Descriptions and details of their use can be found on php.net.

Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

just wondering how do i delete them if they dont logout but press exit on IE or any other browser they go on.

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Lets go back to the beginning.

Are you setting the session variable? If so, how are you setting it (show code).

If you are not setting it then it is an automatic sessionID being set by the server. This will be expired automatically by the server after the period of innactivity specified in the server settings.

Lafinboy
Junior Poster
172 posts since Jul 2004
Reputation Points: 16
Solved Threads: 7
 

hi

i need to install seetion expired on my web page

please email [email]eacarload1@yahoo.com[/email]

or call 516-765-3594

mano3491
Newbie Poster
1 post since Sep 2007
Reputation Points: 10
Solved Threads: 1
 

You can use session_destry() for destroying session.........

I am new with session. What i am trying to do is that if someone doesn't visit my site for lets say 5 day i want the session to expire. is there a way to do this as i am not aware of it.
rajeevkshr
Newbie Poster
19 posts since Dec 2007
Reputation Points: 10
Solved Threads: 1
 

how to create sessionexpire and authentication to the login page by using php code in drupal7

Balajipala
Newbie Poster
1 post since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You