Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: sessions in URL

  1. #1
    New Coder
    Join Date
    Jul 2005
    Posts
    54
    Thanks
    2
    Thanked 1 Time in 1 Post

    sessions in URL

    Hello Peeps

    Hope you can advice on this.

    Can anyone tell me why a session is being appended to a URL

    In my code I have some hard code links like,

    /page.php?xPage=how-to-order.html

    But in the browser it is showing it like.

    http://www.domain.com/page/15cebe915...w-to-order.htm

    Is there a settings in the php.ini doing this.

    I hope you can advise.

    Thanks in advance

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    PHP will append the session ID to a URL automatically if the client has cookies disabled.

  • #3
    New Coder
    Join Date
    Jul 2005
    Posts
    54
    Thanks
    2
    Thanked 1 Time in 1 Post
    But I have cookies enabled and it is still doing it.

    Plus it seems to be random ?

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    If it's random then it's not a PHP setting. Look at your script code and do some tests..

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,044
    Thanks
    2
    Thanked 316 Times in 308 Posts
    If session.use_cookies is zero or off (either it is specifically set to this value or perhaps php cannot find or load the php.ini file) then php will attempt to pass the session ID as a parameter on the url.

    Also, even with session.use_cookies set to one or on and if session.use_trans_sid is set to one or on, php will automatically append the session ID to the url if it cannot set the cookie. If this is occurring, php also only appends the session ID to relative url's. If you use an absolute url - http://somedomain.com... then php does not append the session ID. One or both of these is what I believe is causing the apparent "random" nature of this happening.

    Just because you have cookies enabled in your browser, does not mean that your script is able to send them. Check your web server log for errors and/or turn on full php error reporting. Look for something like "headers could not be sent..."
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

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