Výsledky 1 až 10 z 10

Téma: [PHP] sessions

  1. #1
    Terorista karabínový mince Avatar uživatele PiT
    Založen
    13.09.2002
    Bydliště
    Bratislava
    Příspěvky
    4 550
    Vliv
    300

    Standardní [PHP] sessions

    Rozhodol som sa, ze sa naucim pracovat so sessions...

    Mam PHP 4.3.6, sessions enablovane...

    Nizsie uvedeny kod mi nefunguje, a neviem preco...

    Session mi to v prislusnom adresari normalne vytvori, ale po kliku na link, sa to nikdy nedostane k ELSE...

    Nemam ponatia, preco to nefunguje a zacina ma to pekne srat

    Kód:
    <?php
    if &#40;!session_is_registered&#40;'count'&#41;&#41; &#123;
        session_save_path&#40;'c&#58;/cestaktempdiru/tmp/'&#41;;
        session_register&#40;'count'&#41;;
        $count = 1;
    &#125;
    else &#123;
        $count++;
    &#125;
    ?>
    
    
    Hello visitor, you have seen this page <?php echo $count; ?> times.
    
    
    To continue, ">click here
    Any ideas
    And down we go again, under the relentless wawes, into the arms of calm breakers, into bayou of forgotten dreams
    Like sand slipping through my fingers, nothing ever lasts, ever will

  2. #2

    Standardní

    Nemas tam
    Kód:
      session_name&#40;"neco"&#41;;
      session_start&#40;&#41;;
    To musis mit v kazdem skriptu na zacatku, jinak ti nebude session fungovat.

    Jinak vkladat do session muzes i proste takhle:

    $_SESSION["aaa"] = "bbb";

    PS: Uz je PHP 4.3.11 (a taky 5.0.4)
    Action stations, action stations. Set condition one throughout the ship. This is not a drill.

  3. #3
    Senior Member Avatar uživatele D_a_v_i_d
    Založen
    08.12.2002
    Bydliště
    Praha
    Věk
    44
    Příspěvky
    5 153
    Vliv
    358

    Standardní

    Citace Původně odeslal howard
    Nemas tam
    Kód:
      session_name&#40;"neco"&#41;;
      session_start&#40;&#41;;
    To musis mit v kazdem skriptu na zacatku, jinak ti nebude session fungovat.

    Jinak vkladat do session muzes i proste takhle:

    $_SESSION["aaa"] = "bbb";

    PS: Uz je PHP 4.3.11 (a taky 5.0.4)
    session_name neni potreba... Staci session_start... Funguje mi to uplne v poho...
    A Jedi gains power through understanding; a Sith gains understanding through power

    Destkop machine: Intel Core i5 2400/MSI P67A-C45 /2x4 GB DDR3 1333 MHz/Sapphire HD6790/22" LCD HP w2216/DSL 8MBit connected
    Na filmy v posteli: Lenovo IdeaPad S9e/1,6 GHz Intel Atom, 1 GB RAM, 80 GB HDD
    Na práci: Dell E5500/T9550 2,66 GHz Intel, 3 GB RAM, 120 GB HDD

  4. #4

    Standardní

    A není od věci ukončit stránku kódem:

    Kód:
    Session_write_close&#40;&#41;;
    -- under construction --

  5. #5
    Terorista karabínový mince Avatar uživatele PiT
    Založen
    13.09.2002
    Bydliště
    Bratislava
    Příspěvky
    4 550
    Vliv
    300

    Standardní



    vdaka
    And down we go again, under the relentless wawes, into the arms of calm breakers, into bayou of forgotten dreams
    Like sand slipping through my fingers, nothing ever lasts, ever will

  6. #6
    Senior Member Avatar uživatele D_a_v_i_d
    Založen
    08.12.2002
    Bydliště
    Praha
    Věk
    44
    Příspěvky
    5 153
    Vliv
    358

    Standardní

    Citace Původně odeslal PiT


    vdaka
    A cim to tedy nakonec bylo?
    A Jedi gains power through understanding; a Sith gains understanding through power

    Destkop machine: Intel Core i5 2400/MSI P67A-C45 /2x4 GB DDR3 1333 MHz/Sapphire HD6790/22" LCD HP w2216/DSL 8MBit connected
    Na filmy v posteli: Lenovo IdeaPad S9e/1,6 GHz Intel Atom, 1 GB RAM, 80 GB HDD
    Na práci: Dell E5500/T9550 2,66 GHz Intel, 3 GB RAM, 120 GB HDD

  7. #7

    Standardní

    Citace Původně odeslal D_a_v_i_d
    session_name neni potreba... Staci session_start... Funguje mi to uplne v poho...
    Ale je to lepsi.
    Action stations, action stations. Set condition one throughout the ship. This is not a drill.

  8. #8
    Terorista karabínový mince Avatar uživatele PiT
    Založen
    13.09.2002
    Bydliště
    Bratislava
    Příspěvky
    4 550
    Vliv
    300

    Standardní

    Citace Původně odeslal D_a_v_i_d
    Citace Původně odeslal PiT


    vdaka
    A cim to tedy nakonec bylo?
    session_start...
    Tych ludi, co robili phpManual, by sa zislo obcas preplesknut (podla helpu sa pouzitie session_register zaobide bez session_start)

    Citace Původně odeslal howard
    Citace Původně odeslal D_a_v_i_d
    session_name neni potreba... Staci session_start... Funguje mi to uplne v poho...
    Ale je to lepsi.
    Netreba, pri vytvoreni session pomocou session_register, si meno vytvori automaticky podla parametra funkcie...
    And down we go again, under the relentless wawes, into the arms of calm breakers, into bayou of forgotten dreams
    Like sand slipping through my fingers, nothing ever lasts, ever will

  9. #9
    Senior Member Avatar uživatele D_a_v_i_d
    Založen
    08.12.2002
    Bydliště
    Praha
    Věk
    44
    Příspěvky
    5 153
    Vliv
    358

    Standardní

    Jj, tak jsem to myslel... No nic si z toho nedelej, ja zas myslel onehda, ze se to musi pouzivat JEN pri prvni praci s tou promennou... Proste ze tim STARTem ty promenny nejak "nastartujes" a pak uz to jede Ale ve skutecnosti to musi byt na zacatku kazdyho souboru, kde clovek se sessions dela...
    A Jedi gains power through understanding; a Sith gains understanding through power

    Destkop machine: Intel Core i5 2400/MSI P67A-C45 /2x4 GB DDR3 1333 MHz/Sapphire HD6790/22" LCD HP w2216/DSL 8MBit connected
    Na filmy v posteli: Lenovo IdeaPad S9e/1,6 GHz Intel Atom, 1 GB RAM, 80 GB HDD
    Na práci: Dell E5500/T9550 2,66 GHz Intel, 3 GB RAM, 120 GB HDD

  10. #10
    Senior Member
    Založen
    07.10.2002
    Bydliště
    Ostrava / Straznice
    Příspěvky
    1 133
    Vliv
    289

    Standardní

    Pouzivani session_register se nedoporucuje, viz php manual, mam radeji prime odkazovani v poli, mam pak pocit, ze mam veci vic pod kontrolou

    Kód:
    <?php 
    // Use of session_register&#40;&#41; is deprecated 
    $barney = "A big purple dinosaur."; 
    session_register&#40;"barney"&#41;; 
    
    // Use of $_SESSION is preferred, as of PHP 4.1.0 
    $_SESSION&#91;"zim"&#93; = "An invader from another planet."; 
    
    // The old way was to use $HTTP_SESSION_VARS 
    $HTTP_SESSION_VARS&#91;"spongebob"&#93; = "He's got square pants."; 
    ?>
    Session variables: $_SESSION
    Note:
    Introduced in 4.1.0. In earlier versions, use $HTTP_SESSION_VARS.

    An associative array containing session variables available to the current script. See the Session functions documentation for more information on how this is used.

    This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_SESSION; to access it within functions or methods, as you do with $HTTP_SESSION_VARS.

    $HTTP_SESSION_VARS contains the same information, but is not an autoglobal.
    A jeste k session_unregister

    If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use unset() to unregister a session variable. Do not unset() $_SESSION itself as this will disable the special function of the $_SESSION superglobal.
    Atd proste viz. php manual
    Intel C2D 4300, 1GB DDR2, 120GB Seagate, nVidia7600GT pasiv.

Informace o tématu

Users Browsing this Thread

Toto téma si právě prohlíží 1 uživatelů. (0 registrovaných a 1 anonymních)

Pravidla přispívání

  • Nemůžete zakládat nová témata
  • Nemůžete zasílat odpovědi
  • Nemůžete přikládat přílohy
  • Nemůžete upravovat své příspěvky
  •