Jump to content

Session_id() Question?


Karlos2394

Recommended Posts

Basically, I give each user a different session_id() when they login, and regenerates every 15 mins. However, I was wondering if I could use session_id() as a security measure. I'm not entirely sure if this is a good way to use it, or if i'm using some bits which aren't needed at all.

 

// Function whichs uses session_id()
function Delete() {
global $db, $ir; // $db = Database class || $ir = query for getting users info.
if (isset($_GET['Id'], $_GET['Auth'])) {
  if ($_GET['Id'] && $_GET['Auth'] == session_id() && session_id() == $ir['sId']) {
   $db->query("DELETE FROM `events` WHERE `evID`=".$_GET['Id']." AND `evUSER`=".$ir['userid']);
   $_SESSION['dResult'] = 'Event Deleted';
  } else {
   Error('An error occured while deleting the selected event.');
  }
} else {
  Error('An error occured.');
}
}


// Link to function.
echo '<a href="events.php?act=Delete&Id=',$r['evID'],'&Auth=',session_id(),'">Delete</a><br />';

Link to comment
Share on other sites

However, I was wondering if I could use session_id() as a security measure

In what way?

Your code below just deletes a database record unless i'm missing something. One thing I noticed is that you are comparing the session id against a URL paramater. Passing this value through the url is a bad idea.

$_GET['Auth'] == session_id()

Link to comment
Share on other sites

session_id() merely represents the cookie value for the PHP session identifier.

As neil said, "in what way?" would you envisage using session_id() as a security measure?

It is already partly a security measure in that the session will correlate to whatever identifier comes from the session_id()...

Link to comment
Share on other sites

To be honest I haven't been in web development a long time, so I'm not sure, I was wondering if I was correctly using it, which would be an effective way to use the function. Obviously i'm not, could someone please show me a piece or snippet of code which I can understand how it's effective and secure by using session_id() please?

 

Karlos.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.