SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't Get sessions to work

    I am having problems getting my sessions to work, I know my code is correct I think it is a php thing, heres what I got from phpinfo:

    session
    Session Support enabled

    Directive Local Value Master Value
    session.auto_start
    Off Off
    session.cache_expire
    180 180
    session.cache_limiter
    nocache nocache
    session.cookie_domain
    no value no value
    session.cookie_lifetime
    0 0
    session.cookie_path
    / /
    session.cookie_secure
    Off Off
    session.entropy_file
    no value no value
    session.entropy_length
    0 0
    session.gc_maxlifetime
    1440 1440
    session.gc_probability
    1 1
    session.name
    PHPSESSID PHPSESSID
    session.referer_check
    no value no value
    session.save_handler
    files files
    session.save_path
    /tmp /tmp
    session.serialize_handler
    php php
    session.use_cookies
    Off Off

    does session.use_cookies have to be on? and how do I turn it on.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    When I look at my phpinfo(), session.use_cookies is on. All those session settings are in your php.ini file. The line in my php.ini referring to that variable looks like this:

    ;Whether to use cookies.
    session.use_cookies = 1

    I don't know if you did this or not already, but you have to create a folder anywhere on your computer for sessions to save the session variable information. Then you have to enter the path to that folder in your sessions section of php.ini:

    [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.
    session.save_path = "d:\SessionsFile"

    ; Whether to use cookies.
    session.use_cookies = 1

    Also, at the top of any page in which you want to access session variables you have to have the following code:

    session_start();

    or session_register() which automatically calls session_start().

  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If you server is a Windows computer, you'll have to change the temp directory for session files from '/tmp' (which can't exist on a Windows system) to some temporary directory on your computer.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  4. #4
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its FreeBSD 4.1

    I think my php.ini file is just messed up.

  5. #5
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ok... need help un-messing it?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  6. #6
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually ya...I looked in it, and it was blank!?

    There are 2 in my directory....

    php.ini.default which is huge, and then php.ini which is totally blank? does that mean it is running totally on defaults? and what is the best way to edit these? notepad?

    Maybe I should just delete the blank one, and rename the .default one?

    What should I do?

  7. #7
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Alright here's what php.ini looks like now

    [Session]
    session.save_handler = files ; handler used to store/retrieve data
    session.save_path = /tmp ; argument passed to save_handler
    ; in the case of files, this is the
    ; path where data files are stored
    session.use_cookies = 1 ; whether to use cookies
    session.name = PHPSESSID
    ; name of the session
    ; is used as cookie name
    session.auto_start = 0 ; initialize session on request startup
    session.cookie_lifetime = 0 ; lifetime in seconds of cookie
    ; or if 0, until browser is restarted
    session.cookie_path = / ; the path the cookie is valid for
    session.cookie_domain = ; the domain the cookie is valid for
    session.serialize_handler = php ; handler used to serialize data
    ; php is the standard serializer of PHP
    session.gc_probability = 1 ; percentual probability that the
    ; 'garbage collection' process is started
    ; on every session initialization
    session.gc_maxlifetime = 1440 ; after this number of seconds, stored
    ; data will be seen as 'garbage' and
    ; cleaned up by the gc process
    session.referer_check = ; check HTTP Referer to invalidate
    ; externally stored URLs containing ids
    session.entropy_length = 0 ; how many bytes to read from the file
    session.entropy_file = ; specified here to create the session id
    ; session.entropy_length = 16
    ; session.entropy_file = /dev/urandom
    session.cache_limiter = nocache ; set to {nocache,private,public} to
    ; determine HTTP caching aspects
    session.cache_expire = 180 ; document expires after n minutes
    session.use_trans_sid = 1 ; use transient sid support if enabled
    ; by compiling with --enable-trans-sid
    url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"

    Thats copy and pasted directly from my php.ini file, I over wrote the other blank one with php.ini.default.

  8. #8
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Okay, now if you're on a Windows machine you'll have to change your session.save_path setting.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  9. #9
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but I'm on FreeBSD, I have the folder /tmp on my server, and I have the sessions in vB working sucessfully, it is just my own that don't work, I virtually copy + pasted your tutorial to see if I could get it to work, but I keep getting asked to login, once I submit a page.
    Last edited by WALoeIII; Jun 18, 2001 at 05:56.

  10. #10
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If there's no /tmp, create one and you should be in good shape.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  11. #11
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there is one though, and I can see all the session data from vBulletin in there. I don't get it?

  12. #12
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Snoozy and I spoke over AIM and resolved this problem. Turns out he simply had to restart Apache after making the changes to his php.ini file.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  13. #13
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HEY!

    Now I look dumb! Oh Well, what else is new! he he I'm learning!

  14. #14
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Just think of the people that will read this thread and find the answer they have been searching for! I guarantee you are not the first, nor will you be the last to make that mistake.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •