- 0
[PHP][MySQL] compare session info to db in a query
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By Arceles · Posted
No, you have no idea, if there is a cable.it is prone to that unless it is shielded. -
By wingliston · Posted
Would be cool if the user can drag it around like a widget. Set a boundary so that it cannot go outside the monitor. -
By eilegz · Posted
missing feew things like CPU temp, hopefully they add an option to customize what would i want displayed or not, but as a default and easy msi afterburner alternative its great and it even work on destiny 2 -
By News Staff · Posted
Microsoft Visual Studio Professional 2022 for Windows reaches all-time low price by Steven Parker Today's highlighted deal comes via our Neowin Deals store, where you can save 94% on a copy of Microsoft Visual Studio Professional 2022 for Windows. Visual Studio Professional 2022 is a fully featured development environment that developers around the world know and love. Our first 64-bit IDE makes it easier to work with even bigger projects and more complex workloads. Enhance your productivity, write high-quality code, and re-imagine collaboration with an advanced suite of tools and built-in integrations to tackle the most challenging development workflows and deliver innovative apps. Build across languages & platforms Craft cross-platform mobile and desktop apps with .NET MAUI Build responsive Web UIs in C# with Blazor Build, debug, & test .NET and C++ apps in Linux Use hot reload capabilities across .NET and C++ apps Edit running ASP.NET pages in the web designer view Type less, code more with IntelliCode Understand your code context: variable names, functions, & the type of code you’re writing Complete a line or block of code Get a list of next best options, helping you code more rapidly & accurately Gain deep insights into your code with CodeLens Reveal crucial information like recent changes, authors, tests, and commit history Make informed decisions with a comprehensive overview of your codebase Collaborate seamlessly with Live Share's real-time collaboration sessions Speed up your team's edit & debugging cycles with personalized sessions, access controls, and custom editor settings Ensures everyone's code stays consistent Good to Know ONE-TIME PURCHASE INSTALLED ON 1 DEVICE Redemption deadline: redeem your code within 30 days of purchase Access options: desktop & mobile Version: Professional 2022 Supported languages: Visual Studio is available in English, Chinese (Simplified), Chinese (Traditional), Czech, French, German, Italian, Japanese, Korean, Polish, Portuguese (Brazil), Russian, Spanish, & Turkish Updates included Microsoft Visual Studio Professional 2022 for Windows normally costs $499, but this deal can be yours for just $27.97, that's a saving of $471. For full terms, specifications, and license info, click the link below. Use MSO8 when checking out for additional $8 off. Coupon Expires June 29. Get Microsoft Visual Studio Professional 2022 for Windows for just $19.97, or learn more Although priced in U.S. dollars, this deal is available for digital purchase worldwide. We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce. -
By +sphbecker · Posted
My kids each had a Microsoft account that could log into the family computers, but they did not have admin access, and we didn't have a general guest account or anything like that, so it worked pretty well. You are right, with enough technical knowledge, you can find ways around anything. I still remember I was helping my 10-year-old son with something on his computer and noticed that his account had admin rights. I asked how he did it, and he said he found the BitLocker recovery key, decrypted the drive, then booted a Linux USB and edited the security hive. I told him that if he figured all that out on his own that he deserved admin rights :-)
-
-
Recent Achievements
-
Helen Shafer earned a badge
Week One Done
-
emptyother earned a badge
First Post
-
Crunchy6 earned a badge
Week One Done
-
KynanSEIT earned a badge
One Month Later
-
gowtham07 earned a badge
One Month Later
-
-
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