Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Closing a session and opening a new one

Posted on 2004-04-28
1
Medium Priority
?
3,066 Views
Last Modified: 2013-12-12
In my script I am making sure the user is authentic by storing their IP address in the session when it's created and checking it against their IP address on each page subsequently.  The reason for this is to stop people passing along a URL to a friend with the session ID and that friend getting access to their information (I cannot use cookie sessions).

The problem is this.  If the IP addresses don't match up I want to create a new seperate session for this different user.  There doesn't seem to be an easy way to do this, in essence what I need is a session_stop() function so I can genereate my own ID set it with session_id() then run session_start() again to create the new session.
0
Comment
Question by:sf0a
1 Comment
 
LVL 6

Accepted Solution

by:
jkna_gunn earned 375 total points
ID: 10937061
ok but be warned that doing the security method can kick out legitimate user, aol users seem to be affected by this.
i used to have that code but had to remove it.

in order to kill the session if the ip doesnt match try this:

unset all session variables used (dont do unset($_SESSION) though)

the session_destroy();

the redirect them to a page (login or home perhaps) using header()
the header will not pass the session id along with it so you will get a new session id automatically
if the page your going to has session_start on it.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question