Jump to content
Sign in to follow this  
frosts

no session redirect

Recommended Posts

Sveiki,

Varbūt kāds var palīdzēt sakarā ar sessions?

Izmantoju ipb 3.4.9 (kurš pieejas tpat has.lv forumā), esmu uzstādijis arī ipbwi 3.6.6 ja nemaldos, arī pieejams šeit pat.

esmu izveidoji login.php

 

	 
	<?php
	

 
	    ini_set('display_errors',1);
	 
	    error_reporting(E_ALL);
	 
	    // Initialization
	 
	    require_once('../ipbwi/ipbwi.inc.php');
	 
	    if(isset($_POST['action']) && $_POST['action'] == 'login'){
	 
	            $ipbwi->member->login($_POST['username'],$_POST['password'],$setCookie,$anonLogin);
	 
	        };
	 
	    if($ipbwi->member->isLoggedIn()){
	 
	?>
	 
	        <meta http-equiv="refresh" content="0; url=http://localhost/" />
	 
	<?php
	 
	    }else{
	 
	?>
	 
	        <form action="login.php" method="post">
	 
	            <input style="width:200px;" type="text" name="username" />
	 
	            <input style="width:200px;" type="password" name="password" />
	 
	            <input type="submit" name="login" value="Login" />
	 
	            <input type="hidden" name="action" value="login" />
	 
	        </form>
	 
	<?php
	 
	    }
	 
	?>
	 
	

 

Kā arī register.php

 

	 
	<?php
	 
	    require_once('../ipbwi/ipbwi.inc.php');
	

 
	    if(isset($_POST['action']) && $_POST['action'] == 'register'){
	 
	        if($_POST['password'] != $_POST['password_control']){
	 
	            $ipbwi->addSystemMessage('Error','You have to type the same password for control.');
	 
	        }else{
	 
	            // Q&A Control if needed
	 
	            $question = $GLOBALS['ipbwi']->antispam->qandaGet();
	 
	            if($question !== false){
	 
	                if(!$GLOBALS['ipbwi']->antispam->qandaCheck()){
	 
	                    $GLOBALS['ipbwi']->addSystemMessage('Error', 'Answer of Q&amp;A Challenge not correct');
	 
	                }
	 
	            }
	 
	            // convert custom_fields in a custom array
	 
	            // first check, which custom fields exists
	 
	            $customFields = $ipbwi->member->listCustomFields();
	 
	            // load fielddatas
	 
	            foreach($customFields as $field){
	 
	                // get delivered field datas
	 
	                if(isset($_POST['field_'.$field['pf_id']])){
	 
	                    $fieldDatas['field_'.$field['pf_id']] = $_POST['field_'.$field['pf_id']];
	 
	                }else{
	 
	                    $fieldDatas['field_'.$field['pf_id']] = '';
	 
	                }
	 
	            }
	 
	            if($ipbwi->member->create($_POST['username'], $_POST['password'], $_POST['email'], $fieldDatas, true, $_POST['displayname'])){
	 
	                if($ipbwi->member->login($_POST['username'], $_POST['password'])){
	 
	                    header('location: ../');
	 
	                }
	 
	            }
	 
	        }
	 
	    }
	

 
	    if($ipbwi->member->isLoggedIn()){
	 
	?>
	 
	        <meta http-equiv="refresh" content="0; url=http://localhost/" />
	 
	<?php
	 
	    }else{
	 
	?>
	 
	        <form action="register.php" method="post">
	 
	                <input style="width: 200px;" name="username" type="text" placeholder="Lietotajvards" />
	 
	                <input style="width: 200px;" name="email" type="text"placeholder="e-pasts" />
	 
	                <input style="width: 200px;" name="password" type="password" placeholder="parole" />
	 
	                <input style="width: 200px;" name="password_control" type="password" placeholder="parole velreiz" />
	 
	                <input name="register" value="register" type="submit" placeholder="" />
	 
	<input name="action" value="register" type="hidden" />
	 
	            </table>
	 
	        </form>
	 
	<?php
	 
	    }
	 
	?>
	 
	

 

jautajums ir kur man likt so, ja velos lai ja sesija isloggedin() nav, tad redirect uz login.php lai lietotāji nevar redzēt forumu un citas direktorijas ja nav ielogojusies ?

  session_start();
	    if(isset($_SESSION['isLoggedIn()'])){
	    }else{
	    header("Location: /pages/login.php");
	    }
	

Edited by frosts

Share this post


Link to post
Share on other sites

Paldies par info

	<?php
	session_start();
	if(isset($_SESSION['isLoggedIn()'])){
	}else{
	header('Location: http://localhost/pages/login.php');
	exit;
	};
	

aizmirsis biju "exit;" un ieprieks meta php eroru ka janorada ./opt/lampp/lib/php/

bet tagad ir jauna problema, ka visu laiku met uz login.php kad sesija tiek atrasta..
kad nesmu ielogojies viss normali aizmet uz login.php, bet kad uzspiežu login, tad skraida visu laiku uz localhost gan uz login.php

Edited by frosts

Share this post


Link to post
Share on other sites
<?php
session_start();
if(isset($_SESSION['isLoggedIn()'])) continue; {
} else {
header('Location: http://localhost/pages/login.php');
exit;
};

Pamēģini šādi, bet negarantēju, ka strādās, jo ar php man ir, kā ir...

 

EDIT: Tu vari mēģināt arī šādi:

<?php
session_start();
if(!isset($_SESSION['isLoggedIn()'])){
    header('Location: http://localhost/pages/login.php');
    exit();
};

 

Edited by Jenotinsssss
Koda labojumi.

Share this post


Link to post
Share on other sites

If empty session labāk, un tad nezin kapēc liekas ka to session start neesi pielicis login failam aigšā, ķip. Login. Php failā iekšā

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.