canuhelpme
April 5th, 2007, 01:19 AM
I am trying to implement sessions on my php files.Let files be login1.php and file2.php
Need to be satisfied:
***Access to file2.php should be possible only after successful login.Otherwise noone should be able to access it directly.****
I have now implemented by setting a session in log1.php.On successful log in i am passing the session id to file2.php as follows:
in log1.php......code as follows
session_start();
$sess_id = session_id();
$_SESSION['id']=$sess_id;
if(-------condition)
header("Location: addUser.php?PHPSESSID=$sess_id");
In file2.php i have written it as
session_start();
if($_SESSION['id']!=$_GET['PHPSESSID'] || !isset($_SESSION['id'])){
session_unregister('id');
session_destroy();
header("Location: login1.php");
exit;
}
if i try to access file2.php from anywhere it is not possible.But once if i login successfully and reaches the file2.php i can copy the sessionid from url and if i try to acess the page from anywhere with this id i can get in directly to file2.php.This is the security concern.Then how can i implement sessions for this security.How can i use one more session in a page.Do i need to use another session start.I am not so aware of session implementing.
Need to be satisfied:
***Access to file2.php should be possible only after successful login.Otherwise noone should be able to access it directly.****
I have now implemented by setting a session in log1.php.On successful log in i am passing the session id to file2.php as follows:
in log1.php......code as follows
session_start();
$sess_id = session_id();
$_SESSION['id']=$sess_id;
if(-------condition)
header("Location: addUser.php?PHPSESSID=$sess_id");
In file2.php i have written it as
session_start();
if($_SESSION['id']!=$_GET['PHPSESSID'] || !isset($_SESSION['id'])){
session_unregister('id');
session_destroy();
header("Location: login1.php");
exit;
}
if i try to access file2.php from anywhere it is not possible.But once if i login successfully and reaches the file2.php i can copy the sessionid from url and if i try to acess the page from anywhere with this id i can get in directly to file2.php.This is the security concern.Then how can i implement sessions for this security.How can i use one more session in a page.Do i need to use another session start.I am not so aware of session implementing.