| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Oct 2003
Posts: 3,472
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Sessions (2 Problems) I cant seem to get the data to display from the session, the code im using is below. The header file contains the session_start(); and db information. Heres my full login.php: PHP Code: PHP Code: My next problem is that the session_destroy() isnt working... heres the code PHP Code: |
| |
| | #2 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | In login.php you have a while loop. You do not need this loop as you are retrieving 1 row and I believe this is causing your problem (the session is not being populated) Regarding the session destroy. In which way is it not working? Just a note depending on what is in header (ie how it decides on whether to create a session) your else statement in the last piece of code will never be invoked as session_id() will always contain a session id. I tend to set a constant that declares whether someone is signed in or not. When it comes to the sign out script I check whether that constant is true or false. Although not related to your problem, you are using short tags I highly advise that you stop using them and use the full tags. Some servers have short tags disabled. Standard PHP tags are the only ones guaranteed to work on any server running PHP.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | THREAD STARTER #3 (permalink) | ||||||||
| Senior Member Join Date: Oct 2003
Posts: 3,472
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
its doing this code PHP Code: My header just contains: PHP Code: What do you mean by short tags? I used the code a tutorial had, because Ive never done sessions before... :/ I cant test what you said for the login, because i dont know how to logout ![]()
PHP Code: PHP Code: PHP Code:
__________________ hostvouchers - Coupons and Reviews for the top web hosts! (shared, reseller, vps, servers, adult, offshore, proxy)
Last edited by killaklown; 11-09-2007 at 05:07 PM.
| ||||||||
| |
| | #4 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | short tags are <? ideally you should always use <?PHP A problem you have in your pages is that if(session_id()!='') is never going to be met as at the start of every page load you call session_start() so a session id will always be present.
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |
| | THREAD STARTER #5 (permalink) | ||||||||
| Senior Member Join Date: Oct 2003
Posts: 3,472
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=394109 Oh, i guess thats just a habit now...
| ||||||||
| |
| | #6 (permalink) | ||||
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
PHP Code: ????: NamePros.com http://www.namepros.com/showthread.php?t=394109 if($_SESSION['login']) to logout you would still simply do session_destroy
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft | ||||
| |
| | THREAD STARTER #7 (permalink) |
| Senior Member Join Date: Oct 2003
Posts: 3,472
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Thanks, +rep Gonna try that way, and see what happens. Yep, that fixed the data showing problem, and the logout problem. (getting rid of the 'while' part gave me a white page, so i put it back in, and it worked) Thanks again! (i think i was going to pull some hair out if i couldnt get it fixed today )I just have one question, would doing "$_SESSION['login'] = true;" limit the number of people who can be online at a time? Would it better to use "define('LOGGED_IN',true);" instead?
__________________ hostvouchers - Coupons and Reviews for the top web hosts! (shared, reseller, vps, servers, adult, offshore, proxy)
Last edited by killaklown; 11-09-2007 at 05:47 PM.
|
| |
| | #9 (permalink) |
| NamePros Expert Join Date: Nov 2003 Location: Scotland
Posts: 5,069
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | pm'd you
__________________ Manage your portfolio using my new Domain Portfolio Management script. Securing Your Domain Name From Theft |
| |