Use $_POST variables to transmit session id?

This is a discussion on "Use $_POST variables to transmit session id?" within the PHP Forum section. This forum, and the thread "Use $_POST variables to transmit session id? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 7th, 2007, 16:49
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Use $_POST variables to transmit session id?

Does anyone know (or want to speculate) about using a post-method form with hidden variables to transmit a session id?

I'm thinking that this might be a good way to transmit a session id without requiring the user to allow cookies (which seem to be getting iffier), but with a decent degree of security. If, that is, you don't require much in the way of navigation.

Here's the concept. When the user logs in, pass the session id to a form, and use submit buttons for links with the session id as a hidden input. E.g.
PHP: Select all

<form id="indexform" method="post" action="./sensitivepage.php">
    <div class="formrow"><input type="hidden" name="sessid" value="<?php
 
echo $sessid?>" />
    <input type="submit" class="foo" name="bar" value="Go to the
 Sensitive Page" />
    </div>
</form>
Then at the top of 'directory.php' handle the form, extract the session id as $sessid, set it, and call the session.

Am I missing something huge? The only flaw I can see is that it would become unwieldy for more than a couple of pages.
Reply With Quote

  #2 (permalink)  
Old May 7th, 2007, 17:07
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: Use $_POST variables to transmit session id?

Why is that any better than
Code: Select all
<form id="indexform" method="post" action="./sensitivepage.php?sid=<? echo session_id(); ?>">
?

I can still view source and see the value of your hidden input if I really want to get at the sid. I guess you could encrypt/decrypt it, but you could do that passing it in the querystring as well.
Reply With Quote
  #3 (permalink)  
Old May 7th, 2007, 19:10
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Use $_POST variables to transmit session id?

Bah. No idea really. I'm running on the assumption that it's always safer to bury a variable in the header than to display it in the url.

Last edited by masonbarge; May 7th, 2007 at 19:19.
Reply With Quote
  #4 (permalink)  
Old May 7th, 2007, 19:41
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: Use $_POST variables to transmit session id?

Sometimes less secure is more secure... consider "hiding it in plain sight"... Instead of using "sid=" to pass the sid in the url, use "lang=", and set the session ID to something like "0409" or "useng". All the handling for that will be done server side anyway.

I dunno, I'm sure there are significant flaws to that idea, but it's a creative approach that would probably confuse "the bad people" for a while at least.
Reply With Quote
  #5 (permalink)  
Old May 7th, 2007, 23:21
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: Use $_POST variables to transmit session id?

Actually, now that I think about it, if you're going to set the SID to something specific, you don't even have to pass it.
Reply With Quote
  #6 (permalink)  
Old May 8th, 2007, 10:01
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Use $_POST variables to transmit session id?

Using $_POST and a single hidden field which is the name of a unique session file on the server is a good technique that will work irrespective of cookies. It would, however, be a bad idea to send out all the actual data within hidden field(s) as the geek user could then amend that data before sending it back up.

Note that $_POST will only work if as user browses directly from one page to another and NOT if the goes off to other things and wants to then come back and carry on his session. However, it does not leave a cookie footprint.

I've had a system (written in Perl, so not $_POST) using posted hidden fields running for many years for one of my customers - they use it for time card entry and think it's fabulous because they can all share a PC and each enter their own data with no danger of it being assigned to the wrong person because of old cookies. Also lets them use the data entry even from internet cafes with questionable browser security!
Reply With Quote
  #7 (permalink)  
Old May 8th, 2007, 11:45
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Use $_POST variables to transmit session id?

Quote:
Originally Posted by Donny Bahama View Post
Actually, now that I think about it, if you're going to set the SID to something specific, you don't even have to pass it.
Nah, just a regular random sid. Using a specific sid is a bit wilder than putting it in a POST variable . It certainly has possibilities since you're usually making a sql query anyway.

Since I posted this, I've bumped into it in a couple of places. It's more common than I thought after I first "invented" it.
Reply With Quote
  #8 (permalink)  
Old May 8th, 2007, 11:59
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Use $_POST variables to transmit session id?

Quote:
Originally Posted by grahame View Post
I've had a system (written in Perl, so not $_POST) . . .
Which brings up a tangential question about my personal study.

I have four books in line, all of which look pretty good: Apache, Javascript, XSLT, and Perl. Any advice on which to do first?

*I know some javascript but not enough to really write much code.
*Apache I think I need -- I'm completely lost on shell commands and configuration -- but I don't manage my own server and I no longer have LAMP onboard.
*XSLT, mostly just want it for Ajax and because it's so cool, I'm not creating a feed or anything.
*Perl I don't know anything about, I may not even need it. I do use Perl-flavored regex.
Reply With Quote
  #9 (permalink)  
Old May 8th, 2007, 12:04
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Use $_POST variables to transmit session id?

i tend to use a mixture of methods, some of my variables go into the url, some as sessions... and i occasionally use hidden fields.

Using just one method seems less secure than a mixture to me .... but that might just be my squinty eyes.
Reply With Quote
  #10 (permalink)  
Old May 8th, 2007, 14:03
Reputable Member
Join Date: Mar 2005
Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
Posts: 233
Thanks: 4
Thanked 0 Times in 0 Posts
Re: Use $_POST variables to transmit session id?

What exactly are the security implications wrt the sid? Is it just to do with any sensitive data that might be set in a session var? (But surely it would only be that particular user's sensitive data?)
Reply With Quote
Reply

Tags
php, post, session, sessions

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash and PHP Session Variables saxy46 Flash & Multimedia Forum 0 Jan 27th, 2007 18:21
Session variables ideleon PHP Forum 2 Feb 7th, 2006 08:04
Session Variables.... courtjester Classic ASP 11 Jul 6th, 2004 00:04
Session Variables ekendricks Classic ASP 4 Dec 19th, 2003 06:33
Session Variables ekendricks Classic ASP 7 Aug 26th, 2003 10:42


All times are GMT. The time now is 01:59.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43