Jump to content

Search the Community

Showing results for tags 'include_once session global'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hello everyone! I need help with a problem I'm trying to solve for 2 days now. I know there must be a way and I hope you guys can help me out. What I have here is this. In my website the user is logging in, and I check in the mysql database if the user and password matches. If yes I want to save in php variables all my values from the database such as username, firstname, lastname to use it later on. I can do this but the problem is everytime I go to the page where I use those variables, those are reinitialized and I get the error: Notice: Undefined index: user_id I will write a short example of code with what I try to do: //A.php<?phprequire 'core.inc.php'; // core.inc.php contains the connection to the db and the session_start() login_form(); function login_form(){ $username = $_POST['username']; $password = $_POST['password']; // if username and password are set I do a query on the db and check if it matches // if it matches $_SESSION['user_id'] = $user_id; } ?>--------------------------------------------------------------------------// B.php<?php include 'A.php'; echo $_SESSION['user_id']; ?>Now this works perfectly fine first time I go to B.php the output is 1 or 2 or whatever the session is. But if I go to another page and then go to B.php again the include function is called again so A.php isloaded again, A.php will call core.inc.php so the session is restarted and my variables are set to 0which I don't want. I've tried a lot of things, include_once, include only the variables, global variables, check if the session is started. Nothing worked...Do you lads have a suggestion for me? I would really appreciate it!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.