This is a discussion on "Confused $_SESSION" within the PHP Forum section. This forum, and the thread "Confused $_SESSION are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Confused $_SESSION
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Confused $_SESSION
Hi guys, this is my first post on your forum.
I am not really a newbie to php, but I have been sitting with a problem for about 3 days now. Also posted it on other support forums. Maybe you guys can help. When the Admin signs in, a Session gets created to hold it's user info, and echo it on every page. login.php
These Users have got the same fields as the Admin User, so when the edit form gets submitted, the $_POST somehow replaces the $_SESSION. Which means that all fields that's been changed, now echo the $_POST value of the user who's detail has been changed, instead of the original Admin user's SESSION information. It only happens once Admin chooses another user to edit. And if I go to another Page, the "New SESSION" goes through. I need to know why this happen, or if it's something I'm doing wrong. Here's a shortened version of my page. users.php
When I echo session_id(); it shows the encrypted filename of the Session. Thought it might be something in my php.ini file, but I can't see anything wrong: session.save_handler = files session.save_path = c:/apache/tmp session.use_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.serialize_handler = php session.gc_probability = 1 session.gc_maxlifetime = 1440 session.referer_check = session.entropy_length = 0 session.entropy_file = session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 1 I also tried it with Register Globals on, and off. Please guys, any suggestions? Thanks |
|
|
|
#2
|
|||
|
|||
|
Re: Confused $_SESSION
Ok, I'm now posting print screens, maybe it makes more sense
I'm printing it with the print_r($_SESSION);, so you guys can see the real session values. This is when I land on the page. The Sessions are all correct. ![]() Selected User1 for edit, and change tel. ![]() When for POST, see how the Session changes in the print, but on the left, the Session still shows correctly. ![]() When Selecting Use2 for edit, see how the Session on left also changes ![]() Does this make more sense? Can someone please check the process sequence, and maybe suggest another place to define my Sessions. I'm obviously over complicating it in my own head. Thanks |
|
#3
|
||||
|
||||
|
Re: Confused $_SESSION
Sorry, I tried. It's just too hard to wade through the code. My first suspicion is a variable being reset by a SELECT query.
I do have a possible approach, though, to simplify the code, although it would make automation difficult or maybe impossible. Use .htaccess for the administrator's username and password login. A different range of pluses and minuses, but it's something to consider -- maybe it will at least get you "outside your box". (PS -- it helps, if you're posting a long bit of code on the forum, to use the ENTER key to break lines of code into proper width. Having horizontal and vertical scroll bars on a block of code makes it a major headache to read. If worst comes to worst, you can just put your cursor at the end of every line in the Reply screen and hit ENTER; if it doesn't create a line break, leave it, and if it does create a line break, just backspace.) |
![]() |
| Tags |
| sessions |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| input $_SESSION['username'] = $username; on login page help | Aaron1988 | PHP Forum | 2 | Jan 28th, 2008 14:14 |
| Still confused... PHP | ssnerdy | Starting Out | 14 | Oct 1st, 2007 10:29 |
| Now im really confused | cressy | Scripts and Online Services | 1 | Aug 4th, 2007 08:14 |
| Confused!!! | TwentyFourSeven | Website Planning | 2 | Apr 28th, 2007 05:57 |
| Confused with Actionscript | Diggers23 | Flash & Multimedia Forum | 0 | Jan 29th, 2007 10:35 |