Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sessions and cURL

Featured Replies

Ohai.

 

So, I'm trying to cURL all of the f2p items, and put them into a session. I've added all of the items so they look like $_SESSION['fur'] = ge_item(6814) (Thanks Peter :mrgreen: )

Now I just need to figure out how to use them so that I can just echo $_SESSION['fur'] on any page so that it outputs what it's supposed to be (78)?

 

This is what I have so far:

http://pastebin.com/m6ef72a5b

 

Thank you very much.

Add

session_start();

Just under the <?php tag on every page you need the session data on.

[hide=Drops]

  • Dragon Axe x11
    Berserker Ring x9
    Warrior Ring x8
    Seercull
    Dragon Med
    Dragon Boots x4 - all less then 30 kc
    Godsword Shard (bandos)
    Granite Maul x 3

Solo only - doesn't include barrows[/hide][hide=Stats]

joe_da_studd.png[/hide]

Indeed, make sure that session_start() is before anything is printed. That means that this will not work:

<!doctype html>
<head><title>Blah</title></head>
<html>
<body>
<?php
   session_start();
//Rest of your code here
?>
</body>
</html>

Because session_start() needs to send the headers, if headers are sent before it's called, you'll get an error (Headers already sent in file.php on line X).

 

This is how you'd do it:

 

<?php session_start(); ?>
<!doctype html>
<head><title>Blah</title></head>
<html>
<body>
<?php
//Rest of your code here
?>
</body>
</html>

C2b6gs7.png

...why does it say that PureMageUK wrote this?

I believe he's using his code with permission.

polvCwJ.gif
"It's not a rest for me, it's a rest for the weights." - Dom Mazzetti

Okay, I've added that, but when I try

 

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

The page is blank. Any idea why?

 

I apologize for my ineptitude #-o

 

Make sure you set the session variable before echoing it. Try checking if it's set.

<?php
session_start();
if(isset($_SESSION['fur'])) {
   echo $_SESSION['fur'];
} else {
   echo "It's not set";
}
?>

...why does it say that PureMageUK wrote this?

 

I wrote the functions gp_convert() and ge_item() (the latter of which he's modified) and he's using them with my permission.

 

I'd also like to point out that although I know you're new to PHP that:

  • This isn't the most efficient way to retrieve lots of items as curl_close() is called every time and then it has to be initiated again for the next item.
  • Caching could be used to greatly improve page load times since you won't be pulling from Jagex on every load.

 

Your issue should be sorted by including session_start(); like dsavi said. Ensure you're calling it in the page with the ge_item() calls as well. The session needs to be started for you to be able to assign session variables.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.