Several varied questions follow.
Please be descriptive
- Is this the right format for my cookie?
setcookie("cookiename", $value, time()+50000, "/", ".localhost", false, true);
I want the cookie to be available on localhost and all subdomains of localhost, not be sent over a secure HTTPS connection, but to be sent via HTTPonly.
-
Can someone tell me how the secure attribute works? the manual is a bit vague here, and says it is up to the programmer to make it work on the server side, but that’s all I could find. I am not sure if I turn it on if it does anything.
-
Can there be only one session per site (where php just adds new variables into it on the server), or can there be multiple sessions?
-
Does php have an upper limit as to how much data can be included in a session? (Example: $_SESSION[‘value’] = $value, with hundreds or thousands of other values stored like this.)
-
Is there a security risk in echoing or printing the value of a cookie?
echo $_COOKIE[‘cookiename’]; The user could change it, and I clean it before using it in a database, but I was wondering if there might be some other vulnerability here, such as inserting something like javascript code in a cookie name that might be echoed into the page. -
For mysql database queries - if there are a bunch of queries on a page, one right after another (with some code that works with the result of each query), do I need to call mysqli_close after each query in order to prevent the results of the previous query impacting the next one? I use the same setup, based on a function I wrote, to run any given query. (The function allows me to just work immediately with the fetched row based on a sql query). So many of the variables will be the same. $row[‘id’] might refer to one item in one table, but a different thing in another.
Some background: I am worried about taking a performance hit by closing and re-opening a database connection so many times for basic routines on every page.
Thanks for any help here with my laundry list (I’m open to creating individual threads if one of these topics is bigger than anticipated. Suggestions welcome here.)