Visualizzazione risultati 1 fino 8 di 8

Discussione: sessioni

  1. #1
    Guest

    Predefinito sessioni

    Sto iniziando a studiare le sessioni e ovviamente mi trovo in difficoltà...
    Dovrei fare in modo che non mi crei una sessione nuova ogni volta che utilizzo session_start() a inizio pag. infatti il problema è che al momento in cui crea la sessione nuova perdo tutte le variabili. Ho guardato un po di guide in giro ma non sono molto chiare per quanto riguarda il passaggio dei valori da una pag all'altra tramite sessioni... qualcuno può aiutarmi?
    Ultima modifica di SideExtreme : 13-04-2006 alle ore 02.35.49

  2. #2
    Guest

    Predefinito

    forse dovresti spiegare meglio il tuo problema per capire meglio cosa devi fare.

  3. #3
    L'avatar di funcool
    funcool non è connesso Utente storico
    Data registrazione
    05-02-2004
    Residenza
    Qui... Non lì, qui!
    Messaggi
    15,433

    Predefinito

    Il valore delle sessioni si perde quando si chiude la sessione di lavoro. Quindi avrai scritto del codice scorretto che cancella i valori salvati nelle sessioni. Prova a scrivere qui il tuo codice.
    Mattia vi manda a FunCool - Matriz - Directory Gogol - Sfondo rosso per la Birmania
    «Tu mi dai fastidio perché ti credi tanto un Dio!» «Bè, dovrò pur prendere un modello a cui ispirarmi, no?» Woody Allen

  4. #4
    Ospite Guest

    Predefinito

    I valori possono essere contenuti nell'array "$_SESSION".
    Puoi trovare alcune info utili per ciò che ti occorre fare (se ho ben capito cosa cerchi) qui:
    http://www.phpnews.it/content/view/216/80/1/4/
    http://www.phpnews.it/content/view/74/80/1/1/
    http://www.phpnews.it/content/view/74/80/1/3/
    Esempi di utilizzo qui per far ciò che vuoi tu sn qui:
    http://www.phpnews.it/content/view/74/80/1/2/

  5. #5
    Guest

    Predefinito

    Mah guardate la cosa è piuttosto strana ma provo a spiegarvela.
    Ieri avevo provato a riavviare il computer e magicamente session_start() non creava più sessioni nuove ma riprendeva quella già creata e le variabili funzionavano...
    Ora ho acceso il pc ed ha ricominciato a crearmi sessioni nuove per ogni session_start() a inizio pagina... il codice è corretto:


    pag1.

    Codice PHP:
    <?php
    session_start
    ();

    $_SESSION['var'] = "stringa";

    ?>

    <body>
    <b><a href="t2.php">vai alla pg. successiva</a></b>

    </body>
    pag2

    Codice PHP:
    <?php

    session_start
    ();

    $test = $_SESSION['var'];
    echo
    "stampa sessione ".$test;

    ?>
    Ho notato anche un altro fatto strano...
    Ieri quando le sessioni hanno ripreso a funzionare non mi riconosceva i permessi per accedere a PHPMYADMIN .

    Ora le sessioni non funzionano ma mi fa accede a PHPMYADMIN....

    Secondo me c'è qualcosa che non va a livello di sistema..
    Ultima modifica di SideExtreme : 13-04-2006 alle ore 15.07.16

  6. #6
    L'avatar di funcool
    funcool non è connesso Utente storico
    Data registrazione
    05-02-2004
    Residenza
    Qui... Non lì, qui!
    Messaggi
    15,433

    Predefinito

    Ma cosa ti stampa nella seconda pagina?
    Mattia vi manda a FunCool - Matriz - Directory Gogol - Sfondo rosso per la Birmania
    «Tu mi dai fastidio perché ti credi tanto un Dio!» «Bè, dovrò pur prendere un modello a cui ispirarmi, no?» Woody Allen

  7. #7
    Guest

    Predefinito

    Stampa Notice che significa che la variabile di sessione è vuota.

    Notice: Undefined index: var in c:\documents and settings\sideextreme\documenti\topmeeting\t2.php on line 5
    stampa sessione

    Provate a dare un occhiata al php.ini forse ho settato qualcosa che non va

    Codice:
    [Session]
    ; Handler used to store/retrieve data.
    session.save_handler = files
    
    ; Argument passed to save_handler.  In the case of files, this is the path
    ; where data files are stored. Note: Windows users have to change this 
    ; variable in order to use PHP's session functions.
    session.save_path = "${path}\tmp\"
    ;session.save_path = "C:\Documents and Settings\SideExtreme\Documenti\sideextreme"
    
    ; Whether to use cookies.
    session.use_cookies = 1
    
    ; This option enables administrators to make their users invulnerable to 
    ; attacks which involve passing session ids in URLs; defaults to 0.
    ; session.use_only_cookies = 1
    
    ; Name of the session (used as cookie name).
    session.name = PHPSESSID
    
    ; Initialize session on request startup.
    session.auto_start = 0
    
    ; Lifetime in seconds of cookie or, if 0, until browser is restarted.
    session.cookie_lifetime = 0
    
    ; The path for which the cookie is valid.
    session.cookie_path = \
    
    ; The domain for which the cookie is valid.
    session.cookie_domain =
    
    ; Handler used to serialize data.  php is the standard serializer of PHP.
    session.serialize_handler = php
    
    ; Define the probability that the 'garbage collection' process is started
    ; on every session initialization.
    ; The probability is calculated by using gc_probability/gc_divisor,
    ; e.g. 1/100 means there is a 1% chance that the GC process starts
    ; on each request.
    
    session.gc_probability = 1
    session.gc_divisor     = 1000
    
    ; After this number of seconds, stored data will be seen as 'garbage' and
    ; cleaned up by the garbage collection process.
    session.gc_maxlifetime = 1440
    
    ; PHP 4.2 and less have an undocumented feature/bug that allows you to
    ; to initialize a session variable in the global scope, albeit register_globals
    ; is disabled.  PHP 4.3 and later will warn you, if this feature is used.
    ; You can disable the feature and the warning seperately. At this time,
    ; the warning is only displayed, if bug_compat_42 is enabled.
    
    session.bug_compat_42 = 0
    session.bug_compat_warn = 1
    
    ; Check HTTP Referer to invalidate externally stored URLs containing ids.
    ; HTTP_REFERER has to contain this substring for the session to be
    ; considered as valid.
    session.referer_check =
    
    ; How many bytes to read from the file.
    session.entropy_length = 0
    
    ; Specified here to create the session id.
    session.entropy_file =
    
    ;session.entropy_length = 16
    
    ;session.entropy_file = /dev/urandom
    
    ; Set to {nocache,private,public,} to determine HTTP caching aspects.
    ; or leave this empty to avoid sending anti-caching headers.
    session.cache_limiter = nocache
    
    ; Document expires after n minutes.
    session.cache_expire = 180
    
    ; trans sid support is disabled by default.
    ; Use of trans sid may risk your users security.
    ; Use this option with caution.
    ; - User may send URL contains active session ID
    ;   to other person via. email/irc/etc.
    ; - URL that contains active session ID may be stored
    ;   in publically accessible computer. 
    ; - User may access your site with the same session ID
    ;   always using URL stored in browser's history or bookmarks.
    session.use_trans_sid = 0
    
    ; The URL rewriter will look for URLs in a defined set of HTML tags.
    ; form/fieldset are special; if you include them here, the rewriter will
    ; add a hidden <input> field with the info which is otherwise appended
    ; to URLs.  If you want XHTML conformity, remove the form entry.
    ; Note that all valid entries require a "=", even if no value follows.
    url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
    FunCool: Ricordati di mettere i pezzi di codice tra i tag appositi del forum.

    EDIT: Ho modificato session.use_trans_sid = 1 in php.ini e ora mi riconosce la sessione aperta ma è normale? era una cosa che bisognava fare?
    Il server di Altervista c'è l'ha impostata a 1 ?? o mi ritrovo in difficoltà quando carico il sito sul server?

    EDIT: Su Altervista ho visto che session.use_trans_id è impostata a off ed ho provato a fare un test con le sessioni che fortunatamente funzionano correttamente....
    In locale invece sarò costretto a utilizzare session.use_trans_sid = 1
    Anche se mi piacerebbe capire da cosa dipende...
    Ultima modifica di SideExtreme : 13-04-2006 alle ore 16.47.37

  8. #8
    L'avatar di funcool
    funcool non è connesso Utente storico
    Data registrazione
    05-02-2004
    Residenza
    Qui... Non lì, qui!
    Messaggi
    15,433

    Predefinito

    Per vedere le impostazioni di AlterVista basta che crei un file PHP con questo codice:
    Codice PHP:
    <?
    phpinfo
    ();
    ?>
    P.S.: Non fare UP, usa il tasto Edita.
    Mattia vi manda a FunCool - Matriz - Directory Gogol - Sfondo rosso per la Birmania
    «Tu mi dai fastidio perché ti credi tanto un Dio!» «Bè, dovrò pur prendere un modello a cui ispirarmi, no?» Woody Allen

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •