Solved

Closing a session and opening a new one

Posted on 2004-04-28
1
3,059 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

626 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