2011-09-21 3 views
0
내가 첫 번째 단계가 될 것인가 주제에 읽어하지만 어디 을 시작하는 아무 생각이

?

<?php 
$USR_IS_ADMIN = false; 
$USR_AUTH  = false; 

if($sf_user->hasAttribute('ADMIN')) 
{ 
    $USR_IS_ADMIN = true; 
} 
    $id = $sf_user->getAttribute('profile_id'); 

    if($sf_user->hasAttribute('profile_id') > 0) 
{ 
     $profile = RcProfileTablePeer::getById($id); 
     $activated = $profile->getActivated(); 
     if($activated == 1) 
     { 
     //echo "activated".$activated; 
     $USR_AUTH = true; 
     } 
     else 
     { 
     //echo "NOT activated".$activated; 
    $USR_AUTH = false; 
     } 
} 
    ?> 
    <?php if(!$USR_AUTH) : ?> 
     //show a specific menu here 
    <?php endif;?> 

    <?php if($USR_AUTH):?> 
     //show a different menu here pertaining to logged in user 
    <?php endif;?> 

내 업데이트] factories.yml 파일 :

이 확인 어디에 사용자가 로그인 한 경우 _header.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
    <?php include_http_metas() ?> 
    <?php include_metas() ?> 
    <?php include_title() ?> 
    <link rel="shortcut icon" href="/favicon.ico" /> 
    <?php use_stylesheet('rainbow.css'); ?> 
    <?php use_javascript('rainbow.js'); ?> 
    <?php include_stylesheets(); ?> 
    <?php include_javascripts(); ?> 
</head> 
<body onload='ax_startup();'> 
<center> 
    <?php 
     echo "<div id='div_main_container_rc'>"; 
    ?> 
<div id='div_header_container_rc'> 
    <?php include_component('profile','header'); ?> 
</div> 
    <?php  
      echo "<div id='div_content_container_rc'>"; 
      echo $sf_content; 
      echo "</div>"; 
      echo "<div id='div_footer'>"; 
    ?> 
    //show a footer menu here 
</div> 
</div> 
</center> 
</body> 
</html> 

다음 rclayout.php : 내가 먼저 호출되는 코드를

prod: 
    logger: 
    class: sfNoLogger 
    param: 
    level: err 
    loggers: ~ 

test: 
    storage: 
    class: sfSessionTestStorage 
    param: 
    session_path: %SF_TEST_CACHE_DIR%/sessions 

response: 
    class: sfWebResponse 
    param: 
    send_http_headers: false 

mailer: 
    param: 
    delivery_strategy: none 

dev: 
    mailer: 
    param: 
    delivery_strategy: none 

all: 
    routing: 
    class: sfPatternRouting 
    param: 
    generate_shortest_url:   true 
    extra_parameters_as_query_string: true 

    view_cache_manager: 
    class: sfViewCacheManager 
    param: 
     cache_key_use_vary_headers: true 
     cache_key_use_host_name: true 

user: 
    param: 
    timeout: 300 
내가이 어떻게 할 것입니다 시작해야

? 내가 세션이 어떻게하면 내가 php.ini 파일을 구성 할 장소로 설정된 볼 수 해달라고? 아니면 세션에서이 작업을 수행합니까?

도와주세요? 는

답변

0

은 PHP 세션 메커니즘을 사용한다. 이 세션은 factories.yml을 통해 구성됩니다. 기본 구성은 다음과 같습니다.

user: 
    class: myUser 
    param: 
     timeout:   1800 
     logging:   %SF_LOGGING_ENABLED% 
     use_flash:  true 
     default_culture: %SF_DEFAULT_CULTURE% 

기본적으로 세션은 기본적으로 1800 초 (= 30 분) 후에 시간 초과됩니다.

자신 만 factories.yml 오버라이드 (/lib/vendor/symfony/lib/config에서 찾을 수 있습니다) 심포니에서 기본 factories.yml. 그 factoriesthe user factory is defined like above. So if that configuration is sufficient for you, you don't have to anything. If you want to change the timeout, you can override the appropriate lines in your own .yml factories.yml . In that case you can add to following lines to your own factories.yml`에서 :

user: 
    param: 
     timeout:   900 # log out after 15 minutes 

아, 그리고 난 정말 강하게 _header.php에 뷰에서 로직을 준비하는 것이 좋습니다. if/else 구조를 가진 모든 PHP 코드는 components.class.php이어야하며보기 (_header.php)는 데이터 만보아야합니다.

그래서 이런 식으로 뭔가 :

컨트롤러 :

// components.class.php 
public function executeHeader() { 

    // code here... 
    $this->isAuthenticated = true/false; 
} 

보기 : 그것은 논리에서보기를 seperates

<?php if ($isAuthenticated): ?> 
... 
<?php enif; ?> 
<?php if (!$isAuthenticated): ?> 
... 
<?php enif; ?> 

많은 청소기, 그리고 ... :-)

+0

대단히 고맙습니다 내 공장 파일을 참조하십시오. 난 그냥 코드를 추가 할 수 또는 어떻게 내가 제발 구성합니까? 내가 이해하는 것에서, 사용자는 공장입니다. 그래서 어떻게 클래스에 어떤 이름을 주어야하는지 압니까? 감사합니다 –

+0

내 업데이트 답변보기, 내가 조금 명확하게 ... –

+0

내 업데이트 된 공장 파일을 참조 해 주셔서 감사합니다 ..나는 이것을 300으로 만들었으므로 30/15 분을 기다려야 만하지는 않습니다 ... 타임 아웃 후에 무슨 일이 일어날 지 설명 할 수 있습니까? 내 웹 사이트가 열려 있고 사용자가 로그인했지만 아무 일도 일어나지 않습니까 ?? 내가 아직 로그인 한 상태에서 웹 사이트에서 계속 진행할 수 있습니까 ?? thanks –

1

그냥 당신이 session_destroy()와 함께 할 때 세션이 바르 파괴 감사합니다. 당신은 세션 바르가 사용자 ID가 너무 PHP 매뉴얼에 봐 당신이 unset() 필요 사용자가 로그 아웃 할 경우

<?php 
session_start(); 
Print_r ($_SESSION); 
?> 

그들을 인쇄이 같은 것을 사용할 수 있습니다 설정되는 모르는 경우 기본 PHP 바이

http://php.net/manual/en/function.session-destroy.php (설명을 읽을)

관련 문제