473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Global Values and Security (PHPSESSID)

Thanks for the help and commentary on sessions. I had another question
or two on a related topic. I installed a newer version of php and went
in to set it to read global variables, which was originally set to
'off' when I installed it. The notes in the php.ini file said that
it's less secure to allow reading them. What kind of security risks
would be associated with this? For example, in my site, I just want to
be able to read the PHPSESSID variable so I can keep a visitor logged
in to my site (by comparing the PHPSESSID variable to the most recent
code stored in their row in the database). Although I'm not handling
any kind of monetary transactions on my site, I'd still like it to be
reasonably secure (for learning's sake if nothing else), and I was
wondering:

(1) What kinds of alternatives are there if you don't want to be able
to access global variables... in other words, how else can I pass the
information from page to page without embedding it in hidden forms or
link coding?

(2)What specific security risks are associated with using global
variables as I described above?

thanks

Jonathan
Jul 17 '05 #1
1 3548

"Jonathan" <th***************@yahoo.com> wrote in message
news:67**************************@posting.google.c om...
Thanks for the help and commentary on sessions. I had another question
or two on a related topic. I installed a newer version of php and went
in to set it to read global variables, which was originally set to
'off' when I installed it. The notes in the php.ini file said that
it's less secure to allow reading them. What kind of security risks
would be associated with this? For example, in my site, I just want to
be able to read the PHPSESSID variable so I can keep a visitor logged
in to my site (by comparing the PHPSESSID variable to the most recent
code stored in their row in the database). Although I'm not handling
any kind of monetary transactions on my site, I'd still like it to be
reasonably secure (for learning's sake if nothing else), and I was
wondering:

(1) What kinds of alternatives are there if you don't want to be able
to access global variables... in other words, how else can I pass the
information from page to page without embedding it in hidden forms or
link coding?

(2)What specific security risks are associated with using global
variables as I described above?

thanks

Jonathan


The main issue with enabling global variables is in parsing forms.
Especially
GET forms. It's possible for the user to inject his own values to variables
in
your code. For example, if in your PHP code you have a "private" variable
$username, then the crafty user could easily append "&username=fred" to
the URL. Superglobal variables take precedence over globals, so the
variable in your script would be over-written. By using this method, the
user
can inject potentially damaging values into your code directly. Especially
if
your variables are string variables used directly in database INSERT or
UPDATE queries.... All sorts of nasty things might happen...

Having register_globals on is - therefore - a bad thing. Far better to do
this:

$a_form_variable = !empty($_REQUEST['a_form_variable']) ?
$_REQUEST['a_form_variable'] : null;

Essentially, this checks to see if the requested form variable (you could
substitute
$_POST or $_GET for $_REQUEST) exists, and if it does, equates it to a
script
variable of the same name. If it doesn't exist it equates it to a default
value - null -
which is easy and definite to check against. Then, later in your code, you
can just
compare $a_form_variable to null using === or !== to see whether or not it
contains
a real value.

HTH.

Plankmeister.
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: JohnS | last post by:
Hi, When I initially start my browser (any of 'm) and point it to my PHP script the $PHPSESSID is always blank. On all subsequent hits or after a refresh the value for $PHPSESSID is fine... why...
4
by: Arnaud | last post by:
Hi ! I would like to propagate data between php pages, in two cases : the pages are read by : 1- Internet Explorer It's ok, data are writen in one page, and read from another. I don't use...
0
by: Alex Shi | last post by:
Hi, I don't know how php process its session. I just noticed that for the first time a web site is loaded php will insert a PHPSESSID through out the page: it attach this id to links, insert...
7
by: windandwaves | last post by:
Dear Gurus Is it correct that you do not have to pass the PHPSESSID in the header in order to keep a session going. What are the advantages/disadvantages of having the PHPSESSID in the header ...
2
by: frizzle | last post by:
Hi there I have a site in which all pages ARE php-pages, but they're called/manipulated with htaccess. All files appear as a html-file to surfers. Sometimes i get the PHPSESSID declared in the...
3
by: Dalan | last post by:
I need some assistance or advise in composing code for a global function module or a related one for populating values in text boxes on reports and forms with a name, actually several different...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
3
by: Stephen Kay | last post by:
Sorry fi this is a stupid question - I come from a c/c++ background, and the global variables in php aren't making sense to me. If I want to declare a global variable, say in a global.php file,...
29
by: CAH | last post by:
Hi Can you avoid that googlebot indexes PHPSESSID pages? Googlebot is indexing pages with PHPSESSID, which makes it think my page has a infinite number of pages. How can one avoid this? ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.