|
extracting data from this string....
|
View this Thread in Original format
| UglyDave |
once again - wrong forum. but all u TA people are so damn smart...
trying to read some data from a cookie (written by php) that contains a user id. (in the example below.. the id is 2)
So, from asp.net, can someone suggest a way of extracting the id, or even converting the string below to a more legible format?
Thanks in advance,
Davo
code: a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%22d49614a881b0263d1dda2990012e35a8%22%3Bs%3A
6%3A%22userid%22%3Bs%3A1%3A%222%22%3B%7D
|
|
|
| inconspicuous |
| quote: | Originally posted by UglyDave
converting the string below to a more legible format?
code: a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%22d49614a881b0263d1dda2990012e35a8%22%3Bs%3A
6%3A%22userid%22%3Bs%3A1%3A%222%22%3B%7D
|
a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A32%3A%22d49614a881b0263d1dda2990012e35a8%22%3Bs%3A
6%3A%22userid%22%3Bs%3A1%3A%222%22%3B%7D |
|
|
| Orbax |
in perl youd do a $/ = "%";
then count to 7 and split the string lololol
is it always the 7th "%"? too easy! |
|
|
| Masonious |
ASP should have some URL Decode function, if not you can create one here: http://www.aspnut.com/reference/encoding.asp
using PHP's URLDECODE function that string returns:
a:2:{s:11:"autologinid";s:32:"d49614a881b0263d1dda2990012e35a8";s: 6:"userid";s:1:"2";}
After that it's a simple matter of using either a Regular Expression or a series STRSTR or Search functions to return the location of, "userid"
after that just right trim the length of the string - the integer returned by your string search + 14
then take the left chunk of the string until you find a "
There is an easier way to do this but that's the easiest way i can think of after my 3rd 7&7 |
|
|
| UglyDave |
dont know perl!
just wanna read users id from the forum so i can display a friendly welcome message for them when they arrive on the main site :)
gives a nice wee touch i think! |
|
|
| UglyDave |
| quote: | Originally posted by Masonious
ASP should have some URL Decode function, if not you can create one here: http://www.aspnut.com/reference/encoding.asp
using PHP's URLDECODE function that string returns:
a:2:{s:11:"autologinid";s:32:"d49614a881b0263d1dda2990012e35a8";s: 6:"userid";s:1:"2";}
After that it's a simple matter of using either a Regular Expression or a series STRSTR or Search functions to return the location of, "userid"
after that just right trim the length of the string - the integer returned by your string search + 14
then take the left chunk of the string until you find a "
There is an easier way to do this but that's the easiest way i can think of after my 3rd 7&7 |
cheers dude, appreciate the lengthly reply.
I'll have a go at that now and see what i can come up with.
thanks again! |
|
|
| nchs09 |
| sounds like dubious activities. |
|
|
| UglyDave |
Masonious - asp.net has a similar method Server.UrlDecode()
which returns the same string, I should manage fine from here on,
Thanks again,
David |
|
|
| UglyDave |
| quote: | Originally posted by nchs09
sounds like dubious activities. |
why say ye that? |
|
|
| Orbax |
you mason. cockmongling aristo
la madame guillotine awaits! |
|
|
| nchs09 |
| quote: | Originally posted by UglyDave
why say ye that? | just a guess.... am i wrong?
i dont really care either way:tongue2
or maybe i do now. |
|
|
| UglyDave |
| no no, honnestly. i'm behaving ymself :) |
|
|
|
|