QUOTE(frenz @ Mar 31 2006, 07:04 AM)

I am making a login script which atm uses a cookie to set login status.
I would like to include sessionwise checking into this. And also an IP check, where i write the IP to database and later get it for all other pages and then check it up to the client for each page.
I need to know the commands for:
- getting an IP
- Starting a session
- Ending a session
- Reading a session
IP AddressGetting User's IP - Use $_SERVER['REMOTE_ADDR'] variable
SessionsSessions seem to have been discussed quite a lot in this forum.
Naming A Session - use session_name('sessionName') to name your sessions whatever you want
Starting - Basically include session_start() on all of your pages in order to maintain an open session.
Reading Session - Use $_SESSION['variableName'] to either set or read your session variables
Ending Session - many ways to do it, whatever works for u...example below
CODE
$_SESSION = array(); // clear the universal variable to make sure
if (isset($_COOKIE[session_name()])) {
setcookie(session_name('SessionName'), '', time()-42000, '');
} // clobber the cookie if there is one
session_destroy(); // purge the session record
session_write_close();// not too sure about this <- someone can elaborate
That should do the trick with ending it, or at least it does for me.
Take a look at this thread as it has been already discussed in detail here
http://www.astahost.com/php-sessions-help-t10348.html
Comment/Reply (w/o sign-up)