Solved

Closing a session and opening a new one

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
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 …

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now