gazuraz Posted August 3, 2009 Share Posted August 3, 2009 Basically I am using this code: if (isset($_SESSION['user'])){ $miloica="logout.php"; $pantelija = "logout"; $sesija =$_SESSION["user"]; }else{ $miloica="login.php"; $pantelija = "login/register"; } When user clicks on log in button, log in form opens in a tick box. After the log in confirmation, script redirects user to its control panel which is also in same tick box. After the user finishes his work, or close tick box the button log in remains the same. And it should be Log out..(by the way my boss wants tick box and I cant trow it out) Link to comment https://forums.phpfreaks.com/topic/168660-php-session-problem/ Share on other sites More sharing options...
WolfRage Posted August 3, 2009 Share Posted August 3, 2009 I have no idea what is wrong and what you want, be more specific, show us some more code and walk us through your logic and expected out come, then you will be helped. Link to comment https://forums.phpfreaks.com/topic/168660-php-session-problem/#findComment-889765 Share on other sites More sharing options...
watsmyname Posted August 3, 2009 Share Posted August 3, 2009 Basically I am using this code: if (isset($_SESSION['user'])){ $miloica="logout.php"; $pantelija = "logout"; $sesija =$_SESSION["user"]; }else{ $miloica="login.php"; $pantelija = "login/register"; } When user clicks on log in button, log in form opens in a tick box. After the log in confirmation, script redirects user to its control panel which is also in same tick box. After the user finishes his work, or close tick box the button log in remains the same. And it should be Log out..(by the way my boss wants tick box and I cant trow it out) have you started session in the top of the script?? like session_start(); ?? Link to comment https://forums.phpfreaks.com/topic/168660-php-session-problem/#findComment-889767 Share on other sites More sharing options...
gazuraz Posted August 3, 2009 Author Share Posted August 3, 2009 Basically there is no problem whit session, but there is a huge problem with my boss Session works excellent and I have no problem what so ever with her. /*this code only reads if session is set so it can dynamically format the button*/ session_start(); if (isset($_SESSION['user'])){ $miloica="logout.php"; $pantelija = "logout"; $sesija =$_SESSION["user"]; }else{ $miloica="login.php"; $pantelija = "login/register"; } I have this code on every page beceuse I have one button which is dynamic and if session is set its link shoul be $miloica="logout.php"; and its text should be $pantelija = "logout"; If session is not set its link should be $miloica="login.php"; and its text should be $pantelija = "login/register". That worked OK, until my boss got an idea to open a log in form in tick box (another window). So when user logs in and close that new window the main page dose not refresh so the button link remains $miloica="login.php"; and its text $pantelija = "login/register"; So, actual problem lays in impossibility of php to perform a setInterval() function which I could use to determine the session data and perform the button formatting, whit out using some meta refresh function which will only confuse the user. Now my boss heard that that could be done whit AJAX and he persists, but that will set me back for 5 or six days... So my question is - Is it possible to do it using only php. If not, I would rather use AS button whit loadVars() and setInterval() function than AJAX. Link to comment https://forums.phpfreaks.com/topic/168660-php-session-problem/#findComment-889831 Share on other sites More sharing options...
TeNDoLLA Posted August 3, 2009 Share Posted August 3, 2009 So what is the problem? As a psudeo code it would be ... if (user_is_logged) { $button = '<a href="page.php?logout">Logout</a>'; } else { $button = '<a href="login.php">Login</a>'; } // echo where ever you want your button echo $button; just change the link in the button accordingly on every page load if needed.. edit: added links as a buttons here but you should get the idea. Link to comment https://forums.phpfreaks.com/topic/168660-php-session-problem/#findComment-889841 Share on other sites More sharing options...
gazuraz Posted August 3, 2009 Author Share Posted August 3, 2009 You did not understood me. I already done that. The problem is that user must manually refresh the page from which he used the log in button. Because the log in form opens on another window and not "_self". So the actual session setting dose not reflect the first page which remains opened. If user clicks on another page button, everything is OK. But if user stays on previous page... Link to comment https://forums.phpfreaks.com/topic/168660-php-session-problem/#findComment-889866 Share on other sites More sharing options...
WolfRage Posted August 3, 2009 Share Posted August 3, 2009 You need to use JavaScript to refresh that other page. PHP is doing everything right, but it can not force the client to refresh the page. Link to comment https://forums.phpfreaks.com/topic/168660-php-session-problem/#findComment-889924 Share on other sites More sharing options...
gazuraz Posted August 3, 2009 Author Share Posted August 3, 2009 OK Thanks, I needed to be sure. I Will use As2 button which will reed the session data without refreshing the page... Link to comment https://forums.phpfreaks.com/topic/168660-php-session-problem/#findComment-889998 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.