SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    pass variable between .php pages

    hye guys, i had a problem where i need to pass a variable through .php page. i tried to use SESSION but it seems like after went to a page after another page, the file seems missing. how can i pass the same variable to few .php pages over and over again??

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Marvin_G View Post
    hye guys, i had a problem where i need to pass a variable through .php page. i tried to use SESSION but it seems like after went to a page after another page, the file seems missing. how can i pass the same variable to few .php pages over and over again??
    For every page you wish to access SESSION, you must use session_start(). The session will survive multiple http request, even with a page that does not have the use of sessions.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by K. Wolfe View Post
    For every page you wish to access SESSION, you must use session_start(). The session will survive multiple http request, even with a page that does not have the use of sessions.
    yes i did use that method but after passing the variable to a page then i use windows.history.back () it seems that the previous need to be refresh and it does not look nice after all..any idea?

  4. #4
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Marvin_G View Post
    yes i did use that method but after passing the variable to a page then i use windows.history.back () it seems that the previous need to be refresh and it does not look nice after all..any idea?
    Don't use history back? Why are using that anyway?

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,824
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    history.back will just reload the page from the browser cache - it doesn't download it again from the server and so doesn't have access to changes session values.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    use var_dump for troubleshooting.

  7. #7
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    history.back will just reload the page from the browser cache - it doesn't download it again from the server and so doesn't have access to changes session values.
    the problem is when history.back reload the page from browswer cache, i got an error saying that "Document Expired. This document is no longer available.The requested document is not available in Firefox's cache.As a security precaution, Firefox does not automatically re-request sensitive documents.Click Try Again to re-request the document from the website." so i need to click "try again" everytime after that, then only the page will be reloaded.

  8. #8
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Marvin_G View Post
    the problem is when history.back reload the page from browswer cache, i got an error saying that "Document Expired. This document is no longer available.The requested document is not available in Firefox's cache.As a security precaution, Firefox does not automatically re-request sensitive documents.Click Try Again to re-request the document from the website." so i need to click "try again" everytime after that, then only the page will be reloaded.
    The root of your problem is that your using history.back. User header(), or some other approach.

  9. #9
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by K. Wolfe View Post
    The root of your problem is that your using history.back. User header(), or some other approach.
    can't use header() in javascript. any other suggestion?

  10. #10
    SitePoint Zealot
    Join Date
    Jan 2013
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    problem solved. i used windows.location instead of windows.back. ^^

  11. #11
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by Marvin_G View Post
    problem solved. i used windows.location instead of windows.back. ^^
    Header() is the best practice here. Be in control of your app, don't emulate user interaction like that.


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
  •