Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / PHP - i hate session variables!

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Jul 2015 21:09 Edited at: 26th Jul 2015 21:14
This works perfectly fine:


But this gives me all sorts of errors:




Errors:


I know the member functions in db_inc work as in my first example. But as soon as I try to use a session variable all hell breaks loose. I printed out the session variable using print_r and it appears correct.


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Jul 2015 21:45
I found a work around. Trying to store the database variable in a session seems to reset it or something, thus losing the connection to the db.


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 4th Aug 2015 22:20
sessions can be a pain, I don't think I've ever tried to store a db connection in one, not sure if that really tired best way to go about it too begin with, but you're problem here, it might be generating new sessions instead of resuming an existing one. I've run across that before. make sure you stick a session_start() at the top and do session_write_close() when you are done writing to it.

Login to post a reply

Server time is: 2024-04-26 18:46:17
Your offset time is: 2024-04-26 18:46:17