- 0
[PHP][MySQL] compare session info to db in a query
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By Dutchie64 · Posted
They looked at Apple's silly naming schemes and were ' Hold my beer...." -
By Son_Of_Dad · Posted
Microsoft are pretty good at giving up names without a fight -
By olympus1 · Posted
Brave... the crypto browser with Brave ad rewards and Leo AI everywhere is not an issue for you and Firefox is? At least in Firefox you can disable everything you don't want easily in about:config and everything you don't want is REALLY removed even from the UI. in Brave the only way to really disable all this stuff and them to completely removed from the UI is to use administrator policies. You can only have them turned off without admin policies. -
By zikalify · Posted
The UK shouldn't copy Trump. If the UK wants its own AI Industry it needs to build one, it also need to sort out the issue of startups flying away to America. -
By zikalify · Posted
Azure Linux 2.0 reaches end of life, requiring AKS Arc users to upgrade by Paul Hill Microsoft has warned that Azure Linux 2.0, used in Azure Kubernetes Service (AKS) enabled by Azure Arc, will reach its end of life on July 31, 2025, necessitating users to upgrade. After this date, Microsoft will no longer provide updates, security patches, or support for Azure Linux 2.0. The longer it is used after this date, the more vulnerable systems will become due to a lack of patches. Azure Linux 3.0 brings significant upgrades to core components that enhance performance, security, and the developer experience. The Linux kernel is upgraded from version 5.15 to 6.6, bringing performance and hardware compatibility improvements. The Containerd package has been updated from version 1.6.26 to 1.7.13, improving container management. The SystemD package has been upgraded from version 250 to 255, streamlining system and service management, and OpenSSL has jumped from version 1.1.1k to 3.3.0, providing enhanced encryption and security. Azure Linux 3.0 also brings more packages and better tooling. Major versions of Azure Linux are typically supported for three years, with Azure Linux 3.0’s EOL projected for Summer 2027. It became generally available in August 2024.Microsoft said that users must migrate to Azure Linux 3.0 by upgrading their Azure Local instances to the 2507 release when it becomes available. After the Azure Local instance has been upgraded, users can then upgrade their Kubernetes clusters. Microsoft gives you the option to remain on the same Kubernetes version during this upgrade by providing the same version number on the aksarc upgrade command. After upgrading, you can verify the kernel version on your Linux nodes by adjusting the file path in this command: kubectl --kubeconfig /path/to/aks-cluster-kubeconfig get nodes -o wide This upgrade is mandatory for continued support. If you want to learn more, check out Microsoft’s announcement which also includes how to reach out to the AKS Arc team if you need to.
-
-
Recent Achievements
-
Daniel Pinto earned a badge
Dedicated
-
DougQuaid went up a rank
Explorer
-
MIghty Haul earned a badge
One Month Later
-
MIghty Haul earned a badge
Week One Done
-
KD2004 earned a badge
Collaborator
-
-
Popular Contributors
-
Tell a friend
Question
saiya
Hi,
I got a log-in script going and I have it so it sets up a new session() when it logs the user in.
i have on my index.php a session_start() that stores $_SESSION['user_id'] = $row['user_id']; and $_SESSION['username'] = $row['username'].
then in my account.php I thought of doing the samething and add to my session more information so I did another db query and tried to created my $_SESSION variables to store the extra info I wanted to pull out.
My syntax is correct, and my SQL query is correct aswell.
include 'dbc.php'; page_protect(); session_start(); $row = mysql_fetch_assoc(mysql_query("SELECT company_name FROM agent_company WHERE agent_id = '{$_SESSION['user_id']}'")); if($row['company_name']) { $_SESSION['company_name'] = $row['company_name']; exit; }
as you can see I'm trying to pull the data by comparing that it will only pull that data that belongs to the user of the current session. I used my $_SESSION['user_id'] that was created in my index.php here.
Can I not pull session data on a new page with an existing session? or do I need to add ALL the information I want to use all in one swoop? then just access it later on when I need it...?
in my page_protect() function I have this
function page_protect() { session_start(); //check for cookies if(isset($_COOKIE['user_id']) && isset($_COOKIE['username'])){ $_SESSION['user_id'] = $_COOKIE['user_id']; $_SESSION['username'] = $_COOKIE['username']; } if (!isset($_SESSION['user_id'])) { header("Location: account.php"); }
Link to comment
https://www.neowin.net/forum/topic/897196-phpmysql-compare-session-info-to-db-in-a-query/Share on other sites
36 answers to this question
Recommended Posts