Solved

Closing a session and opening a new one

Posted on 2004-04-28
1
3,050 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 125 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

770 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