Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Session does not work
  • I have folder hierarchy like: My Project Folder
    -> admin
    -assets
    -index.php
    - >AdminApp
    -cache
    -classes
    -config
    .
    .
    . etc
    - >fuel
    -app
    -core
    .
    .
    .etc
    ->public
    -assets
    -index.php
    .
    .
    .
    . etc
    Now I defined one file in "AdminApp\classes\controller\design.php
    and in that I defined method :
    public function action_xyz()
    {
    $param = $_REQUEST ;
    echo $param = Session::get('userName' ) ;
    exit;
    .......
    ......
    ........
    }
    Then I call this controller in "public\assets\js\myscript.js"
    and I got null value for $param,
    and if I call that method in "admin\assets\js\adminScript.js"
    at that time it give me desired output.
    Please help me
    and thx in advance
  • I don't understand what you're trying to do here. Don't use $_REQUEST. Use the Input class. And why getting user input, and then overwriting it with a session variable? Question here is: where is this session variable set? And when? FuelPHP writes the session at the end of the page request, so other requests only have access to it when the request that sets it has finished. Furthermore, when you use cookie based sessions (hint: you shouldn't), you have to take the sequence in which the cookie data in the browser is updated into account.

  • Thx for suggesting me Input class
    Information : I set this session in login controller
    actually two type of user, first one is admin and second is general user
    I created two saparate controller for them. here it is : (information : See path carefully)
    In "AdminApp\classes\controller\welcome"
    public function action_chk_login() // for admin login
    {
    if(UserAuthenticated)
    {
    Session::set('userName',$userName);
    }
    } And In "fuel\classes\controller\welcome"
    public function action_chkLogin()
    { if(generalUserAuthenticated)
    {
    Session::set('userName',$userName);
    } } (See my first Post)
    If Admin login in this site and call XYZ() function at that time session variable have value that is his user name.
    and If General user login in this site and call XYZ() function at that time session variable is null
  • I'm still trying to make heads or tails of what you are doing here. So you have an action called chkLogin(). Which is called from the URL? Which has something abstract called "generalUserAuthenticated" of which I haven't got a clue what it is, and a session variable that is set using the contents of $userName which isn't defined anywhere... Sorry, but I can't do anything with this...
  • ok
    Thank you.
  • Paresh, can you please explain it better what you are trying to do.
  • kevin sakhuja wrote on Saturday 14th of January 2012:
    Paresh, can you please explain it better what you are trying to do.

    That problem is solved.
    But I have one problem in modules
    I want to load assets in mymodules(Module Name : adminpanel) In that "adminpanel\views\welcome\myview.php"
    I used below code <?php
    use Fuel\Core\Asset;
    use Fuel\Core\Session;
    ?>
    <html>
    <head><title>Admin Panel</title>
    <?php Asset::js('jquery.js','script.js');?>
    </head>
    <body>
    <?php echo Session::get('my');?>
    <input type="button" value="Call controller" >
    </body>
    </html> And In "fuel\public\assets\js\script.js"
    $(function(){
    alert("Hello");
    });
    jquery.js and script.js is in include in head section
    any Idea !!!?
  • Yes, read the documentation. The syntax is
    Asset::js( array('jquery.js', script.js') );
    

    Also, don't use Fuel\Core\Asset, use \Asset. Never access core classes directly. All of them are aliased to the global namespace to allow class extensions in your application.
  • Harro Verton wrote on Monday 16th of January 2012:
    Yes, read the documentation. The syntax is
    Asset( array('jquery.js', script.js') );
    

    Also, don't use Fuel\Core\Asset, use \Asset. Never access core classes directly. All of them are aliased to the global namespace to allow class extensions in your application.

    Thx WW
    Here you have to define whether Assets is javascript, Image or CSS so I used
    <?php echo Asset::js(array('jquery.js','script.js'));?>
    And my problem solved
    thanks again.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion