Getting full Page URL and saving it as a session?

Discussion in 'PHP' started by Seqqa, Oct 9, 2008.

  1. #1
    Seqqa, Oct 9, 2008 IP
  2. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #2
    session_start();
    $_SESSION['URL'] = 'http://www.example.com/folder/page.html';
    
    PHP:
    Or you want to detect current page and save it as session?

    session_start();
    $_SESSION['URL'] = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
    
    PHP:
     
    ads2help, Oct 9, 2008 IP
  3. Seqqa

    Seqqa Well-Known Member

    Messages:
    3,695
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    115
    #3
    What would the session be called 'URL'?
     
    Seqqa, Oct 10, 2008 IP
  4. djzmo

    djzmo Active Member

    Messages:
    165
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #4
    	$fullurl = 'http';
    if ($_SERVER['HTTPS'] == 'on') $fullurl .= 's';
    $fullurl .= '://';
    if ($_SERVER['SERVER_PORT'] != '80')
    {
    	$fullurl .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
    }
    else
    {
    	$fullurl .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    }
    $_SESSION['URL'] = $fullurl; // "URL" is the session name. you can change it as you like.
    PHP:
     
    djzmo, Oct 10, 2008 IP
  5. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #5
    It can be any name you want.

    $_SESSION['LOL'] , $_SESSION['HEHE'] can be used too.

    $_SESSION['HEHE'] will carry the URL after you assign value(which is the URL) to it.
     
    ads2help, Oct 10, 2008 IP