burn1337 Posted September 1, 2008 Share Posted September 1, 2008 Ok so I'm tyring to make a login script and the problem is that everytime I log in, only the page that logs me in has my session variables, everytime I try to go to a different page the variables are being lost $Session = new Sessions; $Session->SessionStart(); if (!isset($_SESSION['Uid']) && !isset($_SESSION['UserName'])) { $login = new Login; $login->LoginBox(); } else { $login = new Login; $login->LoggedInBox(); } function Login() { $UserName = $_POST['UserName']; $Password = $_POST['Password']; $Pass = sha1($Password); $query = new Query; $query->GetUser($UserName, $Pass); session_write_close(); } function GetUser($UserName, $Password) { $Check = "select * from Users where userName='$UserName' and password='$Password'"; $Temp = mysql_query($Check) or die("Sorry you must have the wrong UserName and/or Password"); $Row = mysql_fetch_array($Temp); $_SESSION['Uid'] = $Row[0]; $_SESSION['UserName'] = $Row[1]; session_write_close(); } Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/ Share on other sites More sharing options...
ratcateme Posted September 1, 2008 Share Posted September 1, 2008 why are u using $Session = new Sessions; $Session->SessionStart(); opposed to session_start(); Scott. Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-630804 Share on other sites More sharing options...
burn1337 Posted September 1, 2008 Author Share Posted September 1, 2008 well because the function $Sessions->SessionStart() is this: function SessionStart() { //ini_set('session.use_cookies', 1); //ini_set('session.use_only_cookies', 1); ini_set('session.name', 'NewRealm'); session_cache_expire(90); session_save_path('/usr/local/apache2/Session'); session_start(); } Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-630809 Share on other sites More sharing options...
JasonLewis Posted September 1, 2008 Share Posted September 1, 2008 Then you must call that class/function on every page, if you aren't already. Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-630810 Share on other sites More sharing options...
burn1337 Posted September 1, 2008 Author Share Posted September 1, 2008 The way I have it set up is so all I have is one include this way I just have to include the one file. It works, except for when I go to a new page (same include and all) then it just clears the data. I've even tried without the session_write_close() and still nothing. btw this isn't incorporated into my actual site, I'm trying to work out the bugs first lol Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-630813 Share on other sites More sharing options...
burn1337 Posted September 1, 2008 Author Share Posted September 1, 2008 ok this sucks so far no suggestions, only questions lol ok anyway going to bed I hope someone could help me on this.. please Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-630873 Share on other sites More sharing options...
JasonLewis Posted September 1, 2008 Share Posted September 1, 2008 I don't see the need for creating a class for it. Just call it at the top. I mean, you're only calling it once. Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-630875 Share on other sites More sharing options...
burn1337 Posted September 1, 2008 Author Share Posted September 1, 2008 well I was kinda thinkin that too, but if I do it will still be used in my include file, Ill try it in the morning, btw you should check out my site, and if your interested I could use some one to assist me in getting the site done lol. anyways off to never never land night Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-630880 Share on other sites More sharing options...
PFMaBiSmAd Posted September 1, 2008 Share Posted September 1, 2008 Add the following two lines immediately after your <?php tag on all pages - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-630994 Share on other sites More sharing options...
burn1337 Posted September 1, 2008 Author Share Posted September 1, 2008 PFMaBiiSmAd I tried that I get Welcome, Notice: Undefined variable: SESSION in /usr/local/apache2/htdocs/sessions.php on line 39 Monday September 1, 2008, 10:41:46 am Check it is set6 after loggin in, recently it stopped displaying the UserName. after going to the next page I get this. Notice: Undefined index: UserName in /usr/local/apache2/htdocs/sessions.php on line 51 Notice: Undefined index: Password in /usr/local/apache2/htdocs/sessions.php on line 52 Welcome, Notice: Undefined variable: SESSION in /usr/local/apache2/htdocs/sessions.php on line 39 Monday September 1, 2008, 10:43:25 am it is not setUid is null now all the code that is being used has already been posted anything else I may be missing? is my syntax screwed up? is my placement off? what am I doing wrong... btw when I open my cookie with epiphany, I get Expires : end of current session. I have as you can see set the expire time to 90 but it's still not working... could this be something a little more deeper then just php? or is it a picnic error? Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-631312 Share on other sites More sharing options...
burn1337 Posted September 1, 2008 Author Share Posted September 1, 2008 Thanks all for the suggestions and help, I have seemed to fix the problem on my own Thanks everyone SOLVED Quote Link to comment https://forums.phpfreaks.com/topic/122190-having-some-session-problems/#findComment-631338 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.