Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Question about session
  • Could you tell me how I can read session_id?
    I do not fount info in docs.
    I found Session::read(). I want to make shopping cart.
    If user want to add something to cart -
    At firstly session_start, then I write to db'sessions' -> sessions_ID, ip_hash and then in db `cart` I write session id and product id and quantity.
    But I do not know how to extract session id.
  • Why would you need the session id? It's an internal and random value, that regularly changes during the course of a session. You should not use this value in your application.
  • Hello, as of shopping cart, there is already a pakcage from FrenkyNET, look here: https://github.com/FrenkyNet/fuel-cart
  • Harro Verton wrote on Saturday 24th of September 2011:
    Why would you need the session id? It's an internal and random value, that regularly changes during the course of a session. You should not use this value in your application.

    OK. Understood. Other question.
    I want to generate new id for each users.
    $do = \Fuel\Core\Cookie::set('userid',1212121212,3600*60*60,'/','http://a.a')
    $do return TRUE.
    But in cookie I can't see it.
    Nothing.
    Than I write $do2 = \Fuel\Core\Cookie::get('userid');
    var_dump($do2); And Var_dump return nothing.
    I do not understand why?
  • I can imagine that with a domain of "http://a.a", any decent browser will reject the cookie. Use a browser plugin like firebug and/or firefox's web developer toolbar to check the headers being send by the server and the browser, and check which cookies are stored by the browser.
  • Harro Verton wrote on Sunday 25th of September 2011:
    I can imagine that with a domain of "http://a.a", any decent browser will reject the cookie. Use a browser plugin like firebug and/or firefox's web developer toolbar to check the headers being send by the server and the browser, and check which cookies are stored by the browser.

    Thank you! I added plugin HttpFox. I found problem. Also, I want to ask other question about htaccess. 1. I want to see my site.
    2. Firefox -> http://www.myURL.com -> enter
    3. I see folders:
    .git/
        .idea/
        CHANGELOG.md
        README.md
        TESTING.md
        oil
        public/
    
    4. I should to click on public folder , and after that I can see my web site.
    How to make htaccess for URL http://www.myURL.com -> will load automatically public/index.php. And I have problem with URL's in css.
    My css:
    background:url(http://myurl.com/public/assets/img/bullets.png)
    But it is not normal if I write in css Full URL address.
    But if I do not write full url in css - I can't see any style on web page.
    If I correctly understood that problem can be solved with htaccess.
    But how? Help me please. :)
  • The public folder should be the document root of your webserver, so all code is not accessable via the browser.
    If you have access to the webserver's config, the best option is to modify the document root. If you don't, see http://fuelphp.com/docs/installation/instructions.html (installing in the document root). You're css issue is most likely related to the fact that you've installed Fuel incorrect, so fix that first. O, and while you're at it, disable directory indexes ("Options -Indexes"), you should NEVER be able to see the directory structure when browsing to your site.
  • Harro Verton wrote on Monday 26th of September 2011:
    The public folder should be the document root of your webserver, so all code is not accessable via the browser.
    If you have access to the webserver's config, the best option is to modify the document root. If you don't, see http://fuelphp.com/docs/installation/instructions.html (installing in the document root). You're css issue is most likely related to the fact that you've installed Fuel incorrect, so fix that first. O, and while you're at it, disable directory indexes ("Options -Indexes"), you should NEVER be able to see the directory structure when browsing to your site.

    :)
    Thank you! Thank you!
    And sorry for my stupid questions.
  • There are no stupid questions, only stupid answers... ;)
  • Solovej
    and don't forget, that you can use:
    \Cookie::set('userid', $id);
    instead of:
    \Fuel\Core\Cookie::set('userid', $id); Good luck
  • In general, you should NEVER use the \Fuel\Core namespace, unless you know you have a custom class in your app, and you deliberately want to call the core method instead of an overloaded one. If you start calling core methods directly, and later you'll install a package that extends the core class, you'll be spending quite some time debugging your code to find why the package doesn't work as advertised. ;)
  • Thank you! :) Now I want to try to make own cart package.
    Because I do not understand how to use yours cart packages. :( I want to clarify some new my ideas. Cart: If I will Cookie:set('unique users id') and than will work with that unique id like user's id.
    And therefore I could to make manipulation with cart in db.
    My table:
    CREATE TABLE carts (
     cookie_user_id VARCHAR(40) NOT NULL,
     user_id INT(10) UNSIGNED NULL DEFAULT NULL,
     item_id MEDIUMINT(9) UNSIGNED NOT NULL,
     item_quantity TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
     item_price DECIMAL(8,2) UNSIGNED NOT NULL,
     item_color VARCHAR(20) NULL DEFAULT NULL,
     item_size VARCHAR(5) NULL DEFAULT NULL,
     order_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
     UNIQUE INDEX cookie_user_id (cookie_user_id)
    )
    COMMENT='Here cart table, item_color and item_size just for example!!'
    COLLATE='utf8_general_ci'
    ENGINE=InnoDB;
    

    Example:
    1. I enter in URL http://www.myurl.com/macbookpro -> enter. Cookie::set('user_id',Str::random('sha1'),...etc.....); User_id will something like that: sadfkjgdfsaesfsdfasf2423werqew345345345..... 2. Loading page with mac book pro item, photos, description and button BUY IT NOW!
    When I clicked on button BUY IT NOW!
    Item `macbookpro` will write in db `carts`.
    If user to don't want to register he can to checkout without registration.
    If He already registered and logged In He can also to see his order in History.
    So my question is: My idea is True or False ? Do you understood my English?
    :)

Howdy, Stranger!

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

In this Discussion