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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    257
    Thanks
    8
    Thanked 0 Times in 0 Posts

    print phpsessid id

    Hi I have the following code:

    PHP Code:
    session_name("the_ID");
    session_start(); 
    So, I want to print the ID in the url bar like http://myhome.com/index.php?the_ID=here_the_session_id

    How I can do this? Regards

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    865
    Thanks
    7
    Thanked 29 Times in 28 Posts
    you can do this as follow.

    Before sending a response to the browser, you process all links in your website and pass your session id.

    <?php
    # you should check that a session has already started. if not start it
    # before issuing the following statement

    $my_id = "?the_ID=" . $_SESSION['the_ID'];

    # now locate all of your links and append the above variable

    ?>

    I don't know how you are storing your links i.e. files, or in database.

    if in a file... you need to use a regular expression to append the session id in the file. Note: can affect server performance

    good luck

  • #3
    Regular Coder
    Join Date
    Aug 2005
    Posts
    257
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I stores the session ID on a table called "users" in a row "sessionweb" and I put the following code on the head of my page:

    PHP Code:
    session_name('the_ID');
    session_start();
    $my_id "?the_ID=".$_SESSION['the_ID']; 
    and on my Link:
    PHP Code:
    <a href="index.php<? echo $my_id?>">Home</a>
    but it don't show the number id only show in the url bar: http://www.myhome.com/index.php?the_ID=

    What's wrong?

    Regards

  • #4
    Regular Coder
    Join Date
    Aug 2005
    Posts
    257
    Thanks
    8
    Thanked 0 Times in 0 Posts
    solved!

    session_id(); is my solution. Regards


  •  

    Posting Permissions

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