Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Przeniesienie sesji na inny plik
Maxie
post
Post #1





Grupa: Zarejestrowani
Postów: 82
Pomógł: 1
Dołączył: 19.10.2011

Ostrzeżenie: (0%)
-----


Potrzebuje pomocy z przeniesieniem sesji na inny plik, i by był w ten sam sposób wykrywany. Stronę i logowanie mam na index.php, a po zalogowaniu chciałbym by sesja była przeniesiona na main.php, lecz próbowałem chorych sposobów np. na przenoszenie zmiennych itp. ale to nie wyszło. Wiecie jak przenieść sesję?

Pozdrawiam, Maxie.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Maxie
post
Post #2





Grupa: Zarejestrowani
Postów: 82
Pomógł: 1
Dołączył: 19.10.2011

Ostrzeżenie: (0%)
-----


Dobrze więc pokażę co robię i nie działa:

panel.php:
  1. <head>
  2. <style type="text/css">
  3. .style1 {
  4. text-align: center;
  5. }
  6. </style>
  7. </head>
  8.  
  9. <?php include("kick.php"); ?>
  10.  
  11.  
  12. <div class="style1">
  13.  
  14. <script src="http://max.jotfor.ms/min/g=jotform?3.0.1582" type="text/javascript"></script>
  15. <script type="text/javascript">
  16. JotForm.init();
  17. </script>
  18. <link href="http://max.jotfor.ms/min/g=formCss?3.0.1582" rel="stylesheet" type="text/css" />
  19. <style type="text/css">
  20. .form-label{
  21. width:150px !important;
  22. }
  23. .form-label-left{
  24. width:150px !important;
  25. }
  26. .form-line{
  27. padding:10px;
  28. }
  29. .form-label-right{
  30. width:150px !important;
  31. }
  32. .form-all{
  33. width:231px;
  34. color:Black !important;
  35. font-family:Verdana;
  36. font-size:12px;
  37. }
  38. .nowyStyl1 {
  39. font-size: small;
  40. font-family: Arial, Helvetica, sans-serif;
  41. font-style: normal;
  42. text-decoration: underline;
  43. color: #808080;
  44. }
  45. </style>
  46.  
  47. <form class="jotform-form" action="" method="post" name="form_12941309133" id="12941309133" accept-charset="utf-8">
  48. <input type="hidden" name="formID" value="12941309133" />
  49. <div class="form-all">
  50. <ul class="form-section">
  51. <li id="cid_3" class="form-input-wide">
  52. <div class="form-header-group">
  53. <h2 id="header_3" class="form-header">
  54. Panel Użytkownika
  55. </h2>
  56. </div>
  57. </li>
  58. <li class="form-line" id="id_4">
  59. <div id="cid_4" class="form-input-wide">
  60. <div id="text_4" class="form-html">
  61. <p>
  62. Witaj
  63. <strong>
  64. <strong>
  65. <?
  66. echo $_SESSION['USER_ID'];
  67. ?>
  68. </strong>
  69. </strong>
  70. na stronie gł&oacute;wnej.
  71. </p>
  72. </div>
  73. </div>
  74. </li>
  75. <form action="main.php" method="post">
  76. <input type="hidden" name="username" value=" <? echo $_SESSION['USER_ID']; ?> ">
  77.  
  78. <button name="Abutton1" type="submit">Wejdź do gry</button>
  79.  
  80. </form>
  81. <br>
  82. <br>
  83. <a href="http://bornus.cba.pl/index.php?action=logout" class="nowyStyl1">Wyloguj</a>
  84.  


I teraz chcę to odebrać w main.php:

  1. <?
  2. $username = $_POST['username'];
  3. if ($username = NULL){
  4. };
  5. ?>
  6. <head>
  7. <meta http-equiv="Content-Language" content="pl">
  8. <style type="text/css">
  9. .style1 {
  10. text-align: center;
  11. }
  12. .style2 {
  13. border-collapse: collapse;
  14. border: 1px solid #000000;
  15. background-image: url('images/paper_05.png');
  16. }
  17. .style3 {
  18. text-align: center;
  19. border: 1px solid #000000;
  20. }
  21. .style4 {
  22. color: #0099FF;
  23. }
  24. </style>
  25. </head>
  26.  
  27. <body style="background-image: url('images/forum-post-b1.png')">
  28.  
  29. <div class="style1">
  30. <table style="width: 100%" class="style2">
  31. <tr>
  32. <td style="width: 205px; height: 494px" valign="top" class="style3">
  33. Witaj <span class="style4"><?
  34. echo $username;
  35. ?></span>.</td>
  36. Albo (IMG:style_emoticons/default/biggrin.gif) <span class="style4"><?
  37. echo $_POST['username'];
  38. echo $_SESSION['USER_ID'];
  39. ?></span>.</td>
  40.  
  41. <td style="height: 494px"></td>
  42. </tr>
  43. </table>
  44. </div>


Chodzi mi o odebranie przez $_SESSION a nie $_POST, bo przez post to jednorazówka.
Wie ktoś jak to zrobić by przy całej sesji mieć dostęp do $_SESSION['USER_ID'] ?

Ten post edytował Maxie 25.10.2011, 22:15:12
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 5.10.2025 - 17:15