2

I have created a session at my first page:

<?php 
  $youtubeID = get_sub_field('youtube_id'); 
  $withlastSlash = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  $withoutSlash =  substr_replace($withlastSlash, "", -1);
  $howtoURL = $withoutSlash . "?a=" . $youtubeID;
  session_start();
  $_SESSION['howtovidsurl'] = $howtoURL;
?> 

I have then called the session variables in my second page

<?php
    session_start(); 
    echo $_SESSION['howtovidsurl']; 
?> 

But nothing is getting echoed out on the second page.

Bob Smith
  • 53
  • 5
  • First try to print the session variable on same page to check it has no errors and printing something – Virender Kumar Aug 25 '21 at 11:02
  • @VirenderKumar I have tried this and it is printing the correct string. – Bob Smith Aug 25 '21 at 11:14
  • check if session is working in other application if not then try for other xampp installation or try to run this code on your live server – Virender Kumar Aug 25 '21 at 11:26
  • Does this answer your question? [PHP session lost after redirect](https://stackoverflow.com/questions/17242346/php-session-lost-after-redirect) – NcXNaV Aug 25 '21 at 12:04

0 Answers0